Skip to content

Structure error references in range [C3381, C3420] #5678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c3381.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ description: "Microsoft C++ compiler error C3381, its causes and how to resolve
ms.date: 09/28/2020
f1_keywords: ["C3381"]
helpviewer_keywords: ["C3381"]
ms.assetid: d276c89f-8377-4cb6-a8d4-7770885f06c4
---
# Compiler Error C3381

> '*identifier*' : assembly access specifiers are only available in code compiled with a /clr option

A type was declared or defined by using an access specifier, which is only permitted in code compiled by using **`/clr`**.

## Remarks

A type was declared or defined by using an access specifier, which is only permitted in code compiled by using **`/clr`**.

This error may result from a misplaced **`public`**, **`protected`**, or **`private`** keyword, or a missing colon (**`:`**) after an access specifier within a **`class`** or **`struct`**.

In C++/CLI, native types can be visible outside an assembly, but you can only specify assembly access for native types in a **`/clr`** compilation. For more information, see [Type visibility](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Type_visibility) and [`/clr` (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md).

## Example

The following sample generates C3381. To fix it, first either remove the **`public`** specifier from the `class A` definition, or compile by using the **`/clr`** option. Next, add a colon after **`private`** to specify access for `class B {} b;`. That's because a nested class can't have an assembly access specifier as part of its declaration.
The following example generates C3381. To fix it, first either remove the **`public`** specifier from the `class A` definition, or compile by using the **`/clr`** option. Next, add a colon after **`private`** to specify access for `class B {} b;`. That's because a nested class can't have an assembly access specifier as part of its declaration.

```cpp
// C3381.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3382.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C3382"
title: "Compiler Error C3382"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3382"
ms.date: 11/04/2016
f1_keywords: ["C3382"]
helpviewer_keywords: ["C3382"]
ms.assetid: a7603abd-ac4e-4ae6-a02b-3bdc6d1908a6
---
# Compiler Error C3382

'sizeof' is not supported with /clr:safe
> 'sizeof' is not supported with /clr:safe

## Remarks

The output file of a **/clr:safe** compilation is a file that is verifiably type safe, and sizeof is not supported because the return value of the sizeof operator is size_t, whose size varies depending on the operating system.

Expand All @@ -22,7 +23,7 @@ For more information, see,

## Example

The following sample generates C3382.
The following example generates C3382.

```cpp
// C3382.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3383.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C3383"
title: "Compiler Error C3383"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3383"
ms.date: 11/04/2016
f1_keywords: ["C3383"]
helpviewer_keywords: ["C3383"]
ms.assetid: ceb7f725-f417-4dc3-8496-0f413bb76687
---
# Compiler Error C3383

'operator new' is not supported with /clr:safe
> 'operator new' is not supported with /clr:safe

## Remarks

The output file of a **/clr:safe** compilation is a file that is verifiably type safe, and pointers are not supported.

Expand All @@ -20,7 +21,7 @@ For more information, see,

## Example

The following sample generates C3383.
The following example generates C3383.

```cpp
// C3383.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3384.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
---
description: "Learn more about: Compiler Error C3384"
title: "Compiler Error C3384"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3384"
ms.date: 11/04/2016
f1_keywords: ["C3384"]
helpviewer_keywords: ["C3384"]
ms.assetid: c9f92c6a-62a9-4333-b2b1-bc55c7f288b6
---
# Compiler Error C3384

'type_parameter' : the value constraint and the ref constraint are mutually exclusive
> 'type_parameter' : the value constraint and the ref constraint are mutually exclusive

## Remarks

You cannot constrain a generic type to both **`value class`** and **`ref class`**.

See [Constraints on Generic Type Parameters (C++/CLI)](../../extensions/constraints-on-generic-type-parameters-cpp-cli.md) for more information.

## Example

The following sample generates C3384.
The following example generates C3384.

```cpp
// C3384.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3385.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C3385"
title: "Compiler Error C3385"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3385"
ms.date: 11/04/2016
f1_keywords: ["C3385"]
helpviewer_keywords: ["C3385"]
ms.assetid: 5f1838c1-986e-47db-8dbc-e06976b83cf3
---
# Compiler Error C3385

'class::function' : a function that has a DllImport Custom attribute cannot return an instance of a class
> 'class::function' : a function that has a DllImport Custom attribute cannot return an instance of a class

## Remarks

A function defined as being in a .dll file specified with the `DllImport` attribute cannot return an instance of a class.

The following sample generates C3385:
## Example

The following example generates C3385:

```cpp
// C3385.cpp
Expand Down
11 changes: 7 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c3386.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C3386"
title: "Compiler Error C3386"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3386"
ms.date: 11/04/2016
f1_keywords: ["C3386"]
helpviewer_keywords: ["C3386"]
ms.assetid: 93fa8c33-0f10-402b-8eec-b0a217a1f8dc
---
# Compiler Error C3386

> '*type-name*' : `__declspec(dllexport)`/`__declspec(dllimport)` cannot be applied to a managed or WinRT type

## Remarks

The [`dllimport`](../../cpp/dllexport-dllimport.md) and [`dllexport`](../../cpp/dllexport-dllimport.md) **`__declspec`** modifiers aren't valid on a managed or Windows Runtime type.

The following sample generates C3386 and shows how to fix it:
## Example

The following example generates C3386 and shows how to fix it:

```cpp
// C3386.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3387.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C3387"
title: "Compiler Error C3387"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3387"
ms.date: 11/04/2016
f1_keywords: ["C3387"]
helpviewer_keywords: ["C3387"]
ms.assetid: c54d9925-ed14-4976-b8db-e8d4dc84e536
---
# Compiler Error C3387

'member' : __declspec(dllexport)/\__declspec(dllimport) cannot be applied to a member of a managed or WinRT type
> 'member' : __declspec(dllexport)/\__declspec(dllimport) cannot be applied to a member of a managed or WinRT type

## Remarks

The `dllimport` and [dllexport](../../cpp/dllexport-dllimport.md) **`__declspec`** modifiers are not valid on members of a managed or Windows Runtime type.

The following sample generates C3387 and shows how to fix it:
## Example

The following example generates C3387 and shows how to fix it:

```cpp
// C3387a.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3388.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C3388"
title: "Compiler Error C3388"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3388"
ms.date: 11/04/2016
f1_keywords: ["C3388"]
helpviewer_keywords: ["C3388"]
ms.assetid: 34336545-ed13-4d81-ab5f-f869799fe4c2
---
# Compiler Error C3388

'type' : not allowed as a constraint, assuming 'ref class' to continue parsing
> 'type' : not allowed as a constraint, assuming 'ref class' to continue parsing

## Remarks

A constraint was specified on a generic type, but the constraint was not specified correctly. See [Constraints on Generic Type Parameters (C++/CLI)](../../extensions/constraints-on-generic-type-parameters-cpp-cli.md) for more information.

## Example

The following sample generates C3388.
The following example generates C3388.

```cpp
// C3388.cpp
Expand Down
7 changes: 3 additions & 4 deletions docs/error-messages/compiler-errors-2/compiler-error-c3389.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Error C3389"
title: "Compiler Error C3389"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3389"
ms.date: 11/04/2016
f1_keywords: ["C3389"]
helpviewer_keywords: ["C3389"]
ms.assetid: eaaffe17-23f2-413c-b1ad-f7220cfa1334
---
# Compiler Error C3389

Expand All @@ -18,7 +17,7 @@ A [`__declspec`](../../cpp/declspec.md) modifier used implies a per-process stat

## Example

The following sample generates C3389:
The following example generates C3389:

```cpp
// C3389.cpp
Expand Down
9 changes: 4 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3390.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ description: "Microsoft C++ compiler error C3390, its causes and how to resolve
ms.date: 09/26/2020
f1_keywords: ["C3390"]
helpviewer_keywords: ["C3390"]
ms.assetid: 84800a87-c8e6-45aa-82ae-02f816dc8d97
---
# Compiler Error C3390

> '*type_arg*' : invalid type argument for generic parameter '*param*' of generic '*generic_type*', must be a reference type

A generic type was instantiated incorrectly. Check the type definition.

## Remarks

A generic type was instantiated incorrectly. Check the type definition.

For more information, see [Generics](../../extensions/generics-cpp-component-extensions.md).

## Example

The first sample uses C# to create a component that contains a generic type. This type has certain constraints that aren't supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).
The first example uses C# to create a component that contains a generic type. This type has certain constraints that aren't supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).

```csharp
// C3390.cs
Expand All @@ -30,7 +29,7 @@ where V : struct
where N : new() {}
```

When the C3390.dll component is available, the following sample generates C3390.
When the C3390.dll component is available, the following example generates C3390.

```cpp
// C3390_b.cpp
Expand Down
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c3391.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C3391"
title: "Compiler Error C3391"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3391"
ms.date: 11/04/2016
f1_keywords: ["C3391"]
helpviewer_keywords: ["C3391"]
ms.assetid: c32532b9-7db4-4ccd-84b9-479e5a1a19d1
---
# Compiler Error C3391

'type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must be a non-nullable value type
> 'type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must be a non-nullable value type

## Remarks

A generic type was instantiated incorrectly. Check the type definition. For more information, see <xref:System.Nullable> and [Generics](../../extensions/generics-cpp-component-extensions.md).

## Example

The following sample uses C# to create a component that contains a generic type that has certain constraints that are not supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).
The following example uses C# to create a component that contains a generic type that has certain constraints that are not supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).

```csharp
// C3391.cs
Expand All @@ -24,7 +25,7 @@ public class GR<N>
where N : struct {}
```

When the C3391.dll component is available, the following sample generates C3391.
When the C3391.dll component is available, the following example generates C3391.

```cpp
// C3391_b.cpp
Expand Down
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-2/compiler-error-c3392.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C3392"
title: "Compiler Error C3392"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3392"
ms.date: 11/04/2016
f1_keywords: ["C3392"]
helpviewer_keywords: ["C3392"]
ms.assetid: e4757596-e2aa-4314-b01e-5c4bfd2110e9
---
# Compiler Error C3392

'type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must have a public parameterless constructor
> 'type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must have a public parameterless constructor

## Remarks

A generic type was instantiated incorrectly. Check the type definition. For more information, see [Generics](../../extensions/generics-cpp-component-extensions.md).

## Example

The following sample uses C# to create a component that contains a generic type that has certain constraints that are not supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).
The following example uses C# to create a component that contains a generic type that has certain constraints that are not supported when authoring generic types in C++/CLI. For more information, see [Constraints on Type Parameters](/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters).

```csharp
// C3392.cs
Expand All @@ -26,7 +27,7 @@ where V : struct
where N : new() {}
```

When the C3392.dll component is available, the following sample generates C3392.
When the C3392.dll component is available, the following example generates C3392.

```cpp
// C3392_b.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c3393.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C3393"
title: "Compiler Error C3393"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C3393"
ms.date: 11/04/2016
f1_keywords: ["C3393"]
helpviewer_keywords: ["C3393"]
ms.assetid: d57f7c69-0a02-4fe3-9e45-bc62644fd77c
---
# Compiler Error C3393

syntax error in constraint clause: 'identifier' is not a type
> syntax error in constraint clause: 'identifier' is not a type

## Remarks

The identifier passed to a constraint, which must be a type, was not a type. For more information, see [Constraints on Generic Type Parameters (C++/CLI)](../../extensions/constraints-on-generic-type-parameters-cpp-cli.md).

## Example

The following sample generates C3393:
The following example generates C3393:

```cpp
// C3393.cpp
Expand Down
Loading