Skip to content

Structure error references in range [C2461, C2490] #5590

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
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2461.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
---
description: "Learn more about: Compiler Error C2461"
title: "Compiler Error C2461"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2461"
ms.date: 11/04/2016
f1_keywords: ["C2461"]
helpviewer_keywords: ["C2461"]
ms.assetid: e64ba651-f441-4fdb-b5cb-4209bbbe4db4
---
# Compiler Error C2461

> '*class*' : constructor syntax missing formal parameters

## Remarks

The constructor for the class does not specify any formal parameters. The declaration of a constructor must specify a formal parameter list. The list can be empty.

To fix this issue, add a pair of parentheses after the declaration of *class*::**class*.

## Example

The following sample shows how to fix C2461:
The following example shows how to fix C2461:

```cpp
// C2461.cpp
Expand Down
10 changes: 7 additions & 3 deletions docs/error-messages/compiler-errors-1/compiler-error-c2462.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
---
description: "Learn more about: Compiler Error C2462"
title: "Compiler Error C2462"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2462"
ms.date: 11/04/2016
f1_keywords: ["C2462"]
helpviewer_keywords: ["C2462"]
---
# Compiler Error C2462

> 'identifier' : cannot define a type in a 'new-expression'

## Remarks

You cannot define a type in the operand field of the **`new`** operator. Put the type definition in a separate statement.

The following sample generates C2462:
## Example

The following example generates C2462:

```cpp
// C2462.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2464.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2464"
title: "Compiler Error C2464"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2464"
ms.date: 11/04/2016
f1_keywords: ["C2464"]
helpviewer_keywords: ["C2464"]
ms.assetid: ace953d6-b414-49ee-bfef-90578a8da00c
---
# Compiler Error C2464

'identifier' : cannot use 'new' to allocate a reference
> 'identifier' : cannot use 'new' to allocate a reference

## Remarks

A reference identifier was allocated with the **`new`** operator. References are not memory objects, so **`new`** cannot return a pointer to them. Use the standard variable declaration syntax to declare a reference.

The following sample generates C2464:
## Example

The following example generates C2464:

```cpp
// C2464.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2465.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2465"
title: "Compiler Error C2465"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2465"
ms.date: 11/04/2016
f1_keywords: ["C2465"]
helpviewer_keywords: ["C2465"]
ms.assetid: 65ba2a9f-d95e-4af3-b60b-1ac59a1e307c
---
# Compiler Error C2465

cannot define an anonymous type inside parentheses
> cannot define an anonymous type inside parentheses

## Remarks

An anonymous structure, union, or enumerated type is defined inside a parenthetical expression. This is invalid in C++ because the definition is meaningless in function scope.
8 changes: 6 additions & 2 deletions docs/error-messages/compiler-errors-1/compiler-error-c2466.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
---
title: "Compiler Error C2466"
description: "Learn more about: Compiler Error C2466"
ms.date: "03/19/2025"
ms.date: 03/19/2025
f1_keywords: ["C2466"]
helpviewer_keywords: ["C2466"]
---
# Compiler Error C2466

> cannot allocate an array of constant size 0

## Remarks

An array is allocated or declared with size zero. The constant expression for the array size must be an integer greater than zero. An array declaration with a zero subscript is legal only for a class, structure, or union member and only with Microsoft extensions ([/Ze](../../build/reference/za-ze-disable-language-extensions.md)).

The following sample generates C2466:
## Example

The following example generates C2466:

```cpp
// C2466.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2467.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2467"
title: "Compiler Error C2467"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2467"
ms.date: 11/04/2016
f1_keywords: ["C2467"]
helpviewer_keywords: ["C2467"]
ms.assetid: f9ead270-5d0b-41cc-bdcd-586a647c67a7
---
# Compiler Error C2467

illegal declaration of anonymous 'user-defined-type'
> illegal declaration of anonymous 'user-defined-type'

## Remarks

A nested user-defined type was declared. This is an error when compiling C source code with the ANSI compatibility option ([/Za](../../build/reference/za-ze-disable-language-extensions.md)) enabled.

The following sample generates C2467:
## Example

The following example generates C2467:

```c
//C2467.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
title: "Compiler Error C2470"
description: "Learn more about: Compiler Error C2470"
ms.date: "03/29/2025"
ms.date: 03/29/2025
f1_keywords: ["C2470"]
helpviewer_keywords: ["C2470"]
---
# Compiler Error C2470

> '*function*': looks like a function definition, but there is no parameter list; skipping apparent body

## Remarks

A function definition is missing its argument list.

## Example
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2471.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2471"
title: "Compiler Error C2471"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2471"
ms.date: 11/04/2016
f1_keywords: ["C2471"]
helpviewer_keywords: ["C2471"]
ms.assetid: a8928b44-20f6-4cbc-9aa5-7e86052a9c6b
---
# Compiler Error C2471

cannot update program database 'file'
> cannot update program database 'file'

## Remarks

The compiler cannot write to the database file.

Expand Down
7 changes: 3 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2472.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Error C2472"
title: "Compiler Error C2472"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2472"
ms.date: 11/04/2016
f1_keywords: ["C2472"]
helpviewer_keywords: ["C2472"]
ms.assetid: 3b36bcdc-2ba5-4357-ab88-7545ba0551cd
---
# Compiler Error C2472

Expand All @@ -18,7 +17,7 @@ The **/clr:pure** and **/clr:safe** compiler options are deprecated in Visual St

## Example

The following sample generates C2472.
The following example generates C2472.

```cpp
// C2472.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2473.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2473"
title: "Compiler Error C2473"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2473"
ms.date: 11/04/2016
f1_keywords: ["C2473"]
helpviewer_keywords: ["C2473"]
ms.assetid: 6bb7dbf5-b198-490f-860e-fd64d0c2a284
---
# Compiler Error C2473

'identifier' : looks like a function definition, but there is no parameter list.
> 'identifier' : looks like a function definition, but there is no parameter list.

## Remarks

The compiler detected what looked like a function, without the parameter list.

## Example

The following sample generates C2473.
The following example generates C2473.

```cpp
// C2473.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2474.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2474"
title: "Compiler Error C2474"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2474"
ms.date: 11/04/2016
f1_keywords: ["C2474"]
helpviewer_keywords: ["C2474"]
ms.assetid: 64e6c61e-6e77-480e-bcf0-b30a2fc482ac
---
# Compiler Error C2474

'keyword' : missing an adjacent semicolon, could be either keyword or identifier.
> 'keyword' : missing an adjacent semicolon, could be either keyword or identifier.

## Remarks

The compiler expected to find a semicolon, and was unable to determine your intent. Add the semicolon to resolve this error.

## Example

The following sample generates C2474.
The following example generates C2474.

```cpp
// C2474.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2477.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2477"
title: "Compiler Error C2477"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2477"
ms.date: 11/04/2016
f1_keywords: ["C2477"]
helpviewer_keywords: ["C2477"]
ms.assetid: 60bc324b-6605-4833-8099-a291efc712e7
---
# Compiler Error C2477

'member' : static data member cannot be initialized via derived class
> 'member' : static data member cannot be initialized via derived class

## Remarks

A static data member of a template class was initialized incorrectly. This is a breaking change with versions of the Microsoft C++ compiler prior to Visual Studio .NET 2003, in order to conform to the ISO C++ standard.

The following sample generates C2477:
## Example

The following example generates C2477:

```cpp
// C2477.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2479.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2479"
title: "Compiler Error C2479"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2479"
ms.date: 11/04/2016
f1_keywords: ["C2479"]
helpviewer_keywords: ["C2479"]
ms.assetid: c74c7869-e65b-4ca1-b6fa-eb39fed4458a
---
# Compiler Error C2479

'identifier' : 'allocate( )' is only valid for data items of static extent
> 'identifier' : 'allocate( )' is only valid for data items of static extent

## Remarks

The `__declspec( allocate())` syntax can be used for static data only.

The following sample generates C2479:
## Example

The following example generates C2479:

```cpp
// C2479.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2480.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
description: "Learn more about: Compiler Error C2480"
title: "Compiler Error C2480"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2480"
ms.date: 11/04/2016
f1_keywords: ["C2480"]
helpviewer_keywords: ["C2480"]
ms.assetid: 1a58d1c2-971b-4084-96fa-f94aa51c02f1
---
# Compiler Error C2480

'identifier' : 'thread' is only valid for data items of static extent
> 'identifier' : 'thread' is only valid for data items of static extent

## Remarks

You cannot use the `thread` attribute with an automatic variable, nonstatic data member, function parameter, or on function declarations or definitions.

Use the `thread` attribute for global variables, static data members, and local static variables only.

The following sample generates C2480:
## Example

The following example generates C2480:

```cpp
// C2480.cpp
Expand Down
7 changes: 3 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2482.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Error C2482"
title: "Compiler Error C2482"
ms.date: "09/15/2017"
description: "Learn more about: Compiler Error C2482"
ms.date: 09/15/2017
f1_keywords: ["C2482"]
helpviewer_keywords: ["C2482"]
ms.assetid: 98c87da2-625c-4cc2-9bf7-78d15921e779
---
# Compiler Error C2482

Expand All @@ -16,7 +15,7 @@ In managed or WinRT code, variables declared by using the [__declspec(thread)](.

## Example

The following sample generates C2482 in managed (**/clr**) and in WinRT (**/ZW**) code:
The following example generates C2482 in managed (**/clr**) and in WinRT (**/ZW**) code:

```cpp
// C2482.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2483.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2483"
title: "Compiler Error C2483"
ms.date: "09/15/2017"
description: "Learn more about: Compiler Error C2483"
ms.date: 09/15/2017
f1_keywords: ["C2483"]
helpviewer_keywords: ["C2483"]
ms.assetid: 5762b325-914b-442d-a604-e4617ba04038
---
# Compiler Error C2483

>'*identifier*' : object with constructor or destructor cannot be declared 'thread'

## Remarks

This error message is obsolete in Visual Studio 2015 and later versions. In previous versions, variables declared with the `thread` attribute cannot be initialized with a constructor or other expression that requires run-time evaluation. A static expression is required to initialize `thread` data.

## Example

The following sample generates C2483 in Visual Studio 2013 and earlier versions.
The following example generates C2483 in Visual Studio 2013 and earlier versions.

```cpp
// C2483.cpp
Expand Down
Loading