Skip to content

Structure error references in range [C2491, C2520] #5596

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
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2491.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2491"
title: "Compiler Error C2491"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2491"
ms.date: 11/04/2016
f1_keywords: ["C2491"]
helpviewer_keywords: ["C2491"]
ms.assetid: 4e5a8f81-124e-402c-a5ec-d35a89b5469e
---
# Compiler Error C2491

'identifier' : definition of dllimport function not allowed
> 'identifier' : definition of dllimport function not allowed

## Remarks

Data, static data members, and functions can be declared as `dllimport`s but not defined as `dllimport`s.

To fix this issue, remove the `__declspec(dllimport)` specifier from the definition of the function.

The following sample generates C2491:
## Example

The following example generates C2491:

```cpp
// C2491.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2492.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2492"
title: "Compiler Error C2492"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2492"
ms.date: 11/04/2016
f1_keywords: ["C2492"]
helpviewer_keywords: ["C2492"]
ms.assetid: 8c44c9bb-c366-4fe5-a0ab-882e38608aaa
---
# Compiler Error C2492

'*variable*': data with thread storage duration may not have dll interface
> '*variable*': data with thread storage duration may not have dll interface

## Remarks

The variable is declared with the [thread](../../cpp/thread.md) attribute and with the DLL interface. The address of the `thread` variable is not known until run time, so it cannot be linked to a DLL import or export.

The following sample generates C2492:
## Example

The following example generates C2492:

```cpp
// C2492.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2493.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2493"
title: "Compiler Error C2493"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2493"
ms.date: 11/04/2016
f1_keywords: ["C2493"]
helpviewer_keywords: ["C2493"]
ms.assetid: 68316cd5-682b-49c3-b6ea-23c4e5d296cf
---
# Compiler Error C2493

illegal form of __based
> illegal form of __based

## Remarks

A **`__based`** expression must be based on a pointer.

The following sample generates C2493:
## Example

The following example generates C2493:

```cpp
// C2493.cpp
Expand Down
11 changes: 7 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2494.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2494"
title: "Compiler Error C2494"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2494"
ms.date: 11/04/2016
f1_keywords: ["C2494"]
helpviewer_keywords: ["C2494"]
ms.assetid: 5dfd07ab-351d-49c9-b54e-f0a104776ab8
---
# Compiler Error C2494

> '*keyword*' cannot be called from within a filter expression or __finally/finally block

## Remarks

You cannot use *keyword* in a **`__finally`** or **`finally`** block.

The following sample generates C2494:
## Examples

The following example generates C2494:

```cpp
// C2494.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2495.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2495"
title: "Compiler Error C2495"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2495"
ms.date: 11/04/2016
f1_keywords: ["C2495"]
helpviewer_keywords: ["C2495"]
ms.assetid: bb7066fe-3549-4901-97e4-157f3c04dd57
---
# Compiler Error C2495

'identifier' : 'nothrow' can only be applied to function declarations or definitions
> 'identifier' : 'nothrow' can only be applied to function declarations or definitions

## Remarks

The [nothrow](../../cpp/nothrow-cpp.md) extended attribute can be applied to function declarations or definitions only.

The following sample generates C2495:
## Example

The following example generates C2495:

```cpp
// C2495.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2496.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2496"
title: "Compiler Error C2496"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2496"
ms.date: 11/04/2016
f1_keywords: ["C2496"]
helpviewer_keywords: ["C2496"]
ms.assetid: 9a25237d-5bbb-4112-98f3-29cd99d3f89f
---
# Compiler Error C2496

'identifier' : 'selectany' can only be applied to data items with external linkage
> 'identifier' : 'selectany' can only be applied to data items with external linkage

## Remarks

The [selectany](../../cpp/selectany.md) attribute can be applied only to externally visible and global data items.

The following sample generates C2496:
## Example

The following example generates C2496:

```cpp
// C2496.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2498.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2498"
title: "Compiler Error C2498"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2498"
ms.date: 11/04/2016
f1_keywords: ["C2498"]
helpviewer_keywords: ["C2498"]
ms.assetid: 0839f12c-aaa4-4a02-bb33-7f072715dd14
---
# Compiler Error C2498

'function' : 'novtable' can only be applied to class declarations or definitions
> 'function' : 'novtable' can only be applied to class declarations or definitions

## Remarks

This error can be caused by using `__declspec(novtable)` with a function.

## Example

The following sample generates C2498:
The following example generates C2498:

```cpp
// C2498.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2499.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2499"
title: "Compiler Error C2499"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2499"
ms.date: 11/04/2016
f1_keywords: ["C2499"]
helpviewer_keywords: ["C2499"]
ms.assetid: b323ff4d-b3c1-4bfd-b052-ae7292d53222
---
# Compiler Error C2499

'class' : a class cannot be its own base class
> 'class' : a class cannot be its own base class

## Remarks

You attempted to specify the class that you are defining as a base class.

The following sample generates C2499:
## Example

The following example generates C2499:

```cpp
// C2499.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2500.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
description: "Learn more about: Compiler Error C2500"
title: "Compiler Error C2500"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2500"
ms.date: 11/04/2016
f1_keywords: ["C2500"]
helpviewer_keywords: ["C2500"]
ms.assetid: 6bff8161-dc9a-48ca-91f1-fd2eefdbbc93
---
# Compiler Error C2500

'identifier1' : 'identifier2' is already a direct base class
> 'identifier1' : 'identifier2' is already a direct base class

## Remarks

A class or structure appears more than once in a list of base classes.

A direct base is one mentioned in the base list. An indirect base is a base class of one of the classes in the base list.

A class cannot be specified as a direct base class more than once. A class can be used as an indirect base class more than once.

The following sample generates C2500:
## Example

The following example generates C2500:

```cpp
// C2500.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2502.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2502"
title: "Compiler Error C2502"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2502"
ms.date: 11/04/2016
f1_keywords: ["C2502"]
helpviewer_keywords: ["C2502"]
ms.assetid: affa0b86-15fc-4e17-b7f2-6aad4a3771c4
---
# Compiler Error C2502

'identifier' : too many access modifiers on the base class
> 'identifier' : too many access modifiers on the base class

## Remarks

The base class has more than one access modifier. Only one access modifier (**`public`**, **`private`**, or **`protected`**) is allowed.

The following sample generates C2502:
## Example

The following example generates C2502:

```cpp
// C2502.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2503.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2503"
title: "Compiler Error C2503"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2503"
ms.date: 11/04/2016
f1_keywords: ["C2503"]
helpviewer_keywords: ["C2503"]
ms.assetid: da86cc89-fd04-400b-aa8d-a5ffaf7e3918
---
# Compiler Error C2503

'class' : base classes cannot contain zero-sized arrays
> 'class' : base classes cannot contain zero-sized arrays

## Remarks

A base class or structure contains a zero-sized array. An array in a class must have at least one element.

The following sample generates C2503:
## Example

The following example generates C2503:

```cpp
// C2503.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2504.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
description: "Learn more about: Compiler Error C2504"
title: "Compiler Error C2504"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2504"
ms.date: 11/04/2016
f1_keywords: ["C2504"]
helpviewer_keywords: ["C2504"]
ms.assetid: c9e002a6-a4ee-4ba7-970e-edf4adb83692
---
# Compiler Error C2504

'class' : base class undefined
> 'class' : base class undefined

## Remarks

The base class is declared but never defined. Possible causes:

1. Missing include file.

1. External base class not declared with [extern](../../cpp/extern-cpp.md).

The following sample generates C2504:
## Example

The following example generates C2504:

```cpp
// C2504.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2505.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2505"
title: "Compiler Error C2505"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2505"
ms.date: 11/04/2016
f1_keywords: ["C2505"]
helpviewer_keywords: ["C2505"]
ms.assetid: b19f5c53-399d-425e-90db-fe3ca9b40858
---
# Compiler Error C2505

'symbol' : '__declspec(modifer)' can only be applied to declarations or definitions of global objects or static data members
> 'symbol' : '__declspec(modifer)' can only be applied to declarations or definitions of global objects or static data members

## Remarks

A **`__declspec`** modifier that is designed to only be used at global scope was used in a function.

For more information, see [appdomain](../../cpp/appdomain.md) and [process](../../cpp/process.md).

The following sample generates C2505:
## Example

The following example generates C2505:

```cpp
// C2505.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-2/compiler-error-c2506.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
---
description: "Learn more about: Compiler Error C2506"
title: "Compiler Error C2506"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2506"
ms.date: 11/04/2016
f1_keywords: ["C2506"]
helpviewer_keywords: ["C2506"]
ms.assetid: cfed21cd-2404-46f2-985e-d0c2c3820830
---
# Compiler Error C2506

'member' : '__declspec(modifier)' cannot be applied to this symbol
> 'member' : '__declspec(modifier)' cannot be applied to this symbol

## Remarks

You cannot declare per-process or per-appdomain for static members of a managed class.

See [appdomain](../../cpp/appdomain.md) for more information.

## Example

The following sample generates C2506.
The following example generates C2506.

```cpp
// C2506.cpp
Expand Down
Loading