Skip to content

Structure error references in range [C2061, C2080] #5531

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-c2061.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
---
description: "Learn more about: Compiler Error C2061"
title: "Compiler Error C2061"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2061"
ms.date: 11/04/2016
f1_keywords: ["C2061"]
helpviewer_keywords: ["C2061"]
ms.assetid: b0e61c0c-a205-4820-b9aa-301d6c6fe6eb
---
# Compiler Error C2061

syntax error : identifier 'identifier'
> syntax error : identifier 'identifier'

## Remarks

The compiler found an identifier where it wasn't expected. Make sure that `identifier` is declared before you use it.

An initializer may be enclosed by parentheses. To avoid this problem, enclose the declarator in parentheses or make it a **`typedef`**.

This error could also be caused when the compiler detects an expression as a class template argument; use [typename](../../cpp/typename.md) to tell the compiler it is a type, as shown in the following example:

The following sample generates C2061:
## Examples

The following example generates C2061:

```cpp
// C2061.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2062.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2062"
title: "Compiler Error C2062"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2062"
ms.date: 11/04/2016
f1_keywords: ["C2062"]
helpviewer_keywords: ["C2062"]
ms.assetid: 6cc98353-2ddf-43ab-88a2-9cc91cdd6033
---
# Compiler Error C2062

type 'type' unexpected
> type 'type' unexpected

## Remarks

The compiler did not expect a type name.

The following sample generates C2062:
## Example

The following example generates C2062:

```cpp
// C2062.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2063.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2063"
title: "Compiler Error C2063"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2063"
ms.date: 11/04/2016
f1_keywords: ["C2063"]
helpviewer_keywords: ["C2063"]
ms.assetid: 0a90c18f-4029-416a-9128-e8713b53e6f1
---
# Compiler Error C2063

'identifier' : not a function
> 'identifier' : not a function

## Remarks

The identifier is used as a function but not declared as a function.

The following sample generates C2063:
## Example

The following example generates C2063:

```c
// C2063.c
Expand Down
17 changes: 10 additions & 7 deletions docs/error-messages/compiler-errors-1/compiler-error-c2064.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2064"
title: "Compiler Error C2064"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2064"
ms.date: 11/04/2016
f1_keywords: ["C2064"]
helpviewer_keywords: ["C2064"]
ms.assetid: 6cda05da-f437-4f50-9813-ae69538713a3
---
# Compiler Error C2064

term does not evaluate to a function taking N arguments
> term does not evaluate to a function taking N arguments

## Remarks

A call is made to a function through an expression. The expression does not evaluate to a pointer to a function that takes the specified number of arguments.

In this example, the code attempts to call non-functions as functions. The following sample generates C2064:
## Examples

In this example, the code attempts to call non-functions as functions. The following example generates C2064:

```cpp
// C2064.cpp
Expand All @@ -24,7 +27,7 @@ void func() {
}
```

You must call pointers to non-static member functions from the context of an object instance. The following sample generates C2064, and shows how to fix it:
You must call pointers to non-static member functions from the context of an object instance. The following example generates C2064, and shows how to fix it:

```cpp
// C2064b.cpp
Expand All @@ -43,7 +46,7 @@ int main() {
}
```

Within a class, member function pointers must also indicate the calling object context. The following sample generates C2064 and shows how to fix it:
Within a class, member function pointers must also indicate the calling object context. The following example generates C2064 and shows how to fix it:

```cpp
// C2064d.cpp
Expand Down
5 changes: 3 additions & 2 deletions docs/error-messages/compiler-errors-1/compiler-error-c2065.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
description: "Learn more about: Compiler Error C2065"
title: "Compiler Error C2065"
description: "Learn more about: Compiler Error C2065"
ms.date: 06/29/2022
f1_keywords: ["C2065"]
helpviewer_keywords: ["C2065"]
ms.assetid: 78093376-acb7-45f5-9323-5ed7e0aab1dc
---
# Compiler Error C2065

> '*identifier*' : undeclared identifier

## Remarks

The compiler can't find the declaration for an identifier. There are many possible causes for this error. The most common causes of C2065 are that the identifier hasn't been declared, the identifier is misspelled, the header where the identifier is declared isn't included in the file, or the identifier is missing a scope qualifier, for example, `cout` instead of `std::cout`. For more information on declarations in C++, see [Declarations and Definitions (C++)](../../cpp/declarations-and-definitions-cpp.md).

Here are some common issues and solutions in greater detail.
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2066.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2066"
title: "Compiler Error C2066"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2066"
ms.date: 11/04/2016
f1_keywords: ["C2066"]
helpviewer_keywords: ["C2066"]
ms.assetid: f1efc63f-948a-410b-bf6e-ba250d52cd38
---
# Compiler Error C2066

cast to function type is illegal
> cast to function type is illegal

## Remarks

In ANSI C, it is not legal to cast between a function pointer and a data pointer.
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2067.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2067"
title: "Compiler Error C2067"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2067"
ms.date: 11/04/2016
f1_keywords: ["C2067"]
helpviewer_keywords: ["C2067"]
ms.assetid: 97cab473-a713-489f-8536-ca2cc5792b8c
---
# Compiler Error C2067

cast to array type is illegal
> cast to array type is illegal

## Remarks

An object was cast to an array type.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2068"
title: "Compiler Error C2068"
description: "Learn more about: Compiler Error C2068"
ms.date: 08/18/2022
f1_keywords: ["C2068"]
helpviewer_keywords: ["C2068"]
Expand All @@ -9,8 +9,12 @@ helpviewer_keywords: ["C2068"]

> illegal use of overloaded function. Missing argument list?

## Remarks

The compiler detected the invalid use of an overloaded function with no arguments.

## Example

For example:

```cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2069.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2069"
title: "Compiler Error C2069"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2069"
ms.date: 11/04/2016
f1_keywords: ["C2069"]
helpviewer_keywords: ["C2069"]
ms.assetid: 0c87445a-9eed-4917-a733-f08217f2d64d
---
# Compiler Error C2069

cast of 'void' term to non-'void'
> cast of 'void' term to non-'void'

## Remarks

Type **`void`** cannot be cast to any other type.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2070.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2070"
title: "Compiler Error C2070"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2070"
ms.date: 11/04/2016
f1_keywords: ["C2070"]
helpviewer_keywords: ["C2070"]
ms.assetid: 4c8dea63-1227-4aba-be26-2462537f86fb
---
# Compiler Error C2070

'type': illegal sizeof operand
> 'type': illegal sizeof operand

## Remarks

The [sizeof](../../cpp/sizeof-operator.md) operator requires an expression or type name.

The following sample generates C2070:
## Example

The following example generates C2070:

```cpp
// C2070.cpp
Expand Down
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-1/compiler-error-c2071.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
---
description: "Learn more about: Compiler Error C2071"
title: "Compiler Error C2071"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2071"
ms.date: 11/04/2016
f1_keywords: ["C2071"]
helpviewer_keywords: ["C2071"]
ms.assetid: f8c09255-a5c4-47e3-8089-3d875ae43cc5
---
# Compiler Error C2071

'identifier' : illegal storage class
> 'identifier' : illegal storage class

## Remarks

`identifier` was declared with an invalid [storage class](../../c-language/c-storage-classes.md). This error can be caused when more than one storage class is specified for an identifier, or when the definition is incompatible with the storage class declaration.

To fix this issue, understand the intended storage class of the identifier—for example, **`static`** or **`extern`**—and correct the declaration to match.

## Examples

The following sample generates C2071.
The following example generates C2071.

```cpp
// C2071.cpp
Expand All @@ -29,7 +30,7 @@ struct D {
};
```

The following sample generates C2071.
The following example generates C2071.

```cpp
// C2071_b.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2072.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2072"
title: "Compiler Error C2072"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2072"
ms.date: 11/04/2016
f1_keywords: ["C2072"]
helpviewer_keywords: ["C2072"]
ms.assetid: 0b19a847-61dd-4bc3-b54d-108a637a4424
---
# Compiler Error C2072

'identifier' : initialization of a function
> 'identifier' : initialization of a function

## Remarks

A function initializer was specified incorrectly.
5 changes: 2 additions & 3 deletions docs/error-messages/compiler-errors-1/compiler-error-c2073.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
description: "Learn more about: Compiler Error C2073"
title: "Compiler Error C2073"
description: "Learn more about: Compiler Error C2073"
ms.date: 06/29/2022
f1_keywords: ["C2073"]
helpviewer_keywords: ["C2073"]
ms.assetid: 57908234-be7a-4ce9-b0a7-8b1ad621865e
---
# Compiler Error C2073

Expand All @@ -18,7 +17,7 @@ This compiler error is obsolete in Visual Studio 2022.

## Example

The following sample generates C2073. Source file `C2073.cpp`:
The following example generates C2073. Source file `C2073.cpp`:

```cpp
// C2073.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2074.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2074"
title: "Compiler Error C2074"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2074"
ms.date: 11/04/2016
f1_keywords: ["C2074"]
helpviewer_keywords: ["C2074"]
ms.assetid: 1abe5934-61db-4374-8c48-1fa7281317f4
---
# Compiler Error C2074

'identifier' : 'class-key' initialization needs curly braces
> 'identifier' : 'class-key' initialization needs curly braces

## Remarks

There were no curly braces around the specified class, structure, or union initializer.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2075.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2075"
title: "Compiler Error C2075"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2075"
ms.date: 11/04/2016
f1_keywords: ["C2075"]
helpviewer_keywords: ["C2075"]
ms.assetid: 8b1865d2-540b-4117-b982-e7a58a0b6cf7
---
# Compiler Error C2075

'identifier' : array initialization needs curly braces
> 'identifier' : array initialization needs curly braces

## Remarks

There were no curly braces around the specified array initializer.

The following sample generates C2075:
## Example

The following example generates C2075:

```c
// C2075.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2076"
title: "Compiler Error C2076"
description: "Learn more about: Compiler Error C2076"
ms.date: 08/18/2022
f1_keywords: ["C2076"]
helpviewer_keywords: ["C2076"]
Expand All @@ -9,6 +9,8 @@ helpviewer_keywords: ["C2076"]

> a brace-enclosed initializer list cannot be used in a new-expression whose type contains 'auto/decltype(auto)'

## Remarks

If an **`auto`** type-specifier appears in the specifier sequence of a new type-identifier or the type-identifier of a **`new`** expression, the expression must contain an initializer of the form `( assignment-expression )`. The compiler deduces the type-identifier from the `assignment-expression` in the initializer. For example,

```cpp
Expand Down
Loading