Skip to content

Structure error references in range [C2141, C2160] #5546

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

Merged
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
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2141.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2141"
title: "Compiler Error C2141"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2141"
ms.date: 11/04/2016
f1_keywords: ["C2141"]
helpviewer_keywords: ["C2141"]
ms.assetid: 10cf770f-0500-4220-ac90-a863b7ea5fe6
---
# Compiler Error C2141

array size overflow
> array size overflow

## Remarks

An array exceeds the 2GB limit. Reduce the size of the array.

## Example

The following sample generates C2141.
The following example generates C2141.

```cpp
// C2141.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2142.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2142"
title: "Compiler Error C2142"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2142"
ms.date: 11/04/2016
f1_keywords: ["C2142"]
helpviewer_keywords: ["C2142"]
ms.assetid: d0dbe10e-0952-49a4-8b33-e82fb7558b19
---
# Compiler Error C2142

function declarations differ, variable parameters specified only in one of them
> function declarations differ, variable parameters specified only in one of them

## Remarks

One declaration of the function contains a variable parameter list. Another declaration does not. ANSI C ([/Za](../../build/reference/za-ze-disable-language-extensions.md)) only.

The following sample generates C2142:
## Example

The following example generates C2142:

```c
// C2142.c
Expand Down
11 changes: 7 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2143.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
---
description: "Learn more about: Compiler Error C2143"
title: "Compiler Error C2143"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2143"
ms.date: 11/04/2016
f1_keywords: ["C2143"]
helpviewer_keywords: ["C2143"]
ms.assetid: 1d8d1456-e031-4965-9240-09a6e33ba81c
---
# Compiler Error C2143

syntax error : missing 'token1' before 'token2'
> syntax error : missing 'token1' before 'token2'

## Remarks

The compiler expected a specific token (that is, a language element other than white space) and found another token instead.

Check the [C++ Language Reference](../../cpp/cpp-language-reference.md) to determine where code is syntactically incorrect. Because the compiler may report this error after it encounters the line that causes the problem, check several lines of code that precede the error.

C2143 can occur in different situations.

## Examples

It can occur when an operator that can qualify a name (`::`, `->`, and `.`) must be followed by the keyword **`template`**, as in this example:

```cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2144.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
description: "Learn more about: Compiler Error C2144"
title: "Compiler Error C2144"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2144"
ms.date: 11/04/2016
f1_keywords: ["C2144"]
helpviewer_keywords: ["C2144"]
ms.assetid: 49f3959b-324f-4c06-9588-c0ecef5dc5b3
---
# Compiler Error C2144

> syntax error : '*type*' should be preceded by '*token*'

## Remarks

The compiler expected *token* and found *type* instead.

This error may be caused by a missing closing brace, right parenthesis, or semicolon.
Expand All @@ -20,7 +21,7 @@ You may also see C2144 if you are trying to do type forwarding. See [Type Forwar

## Examples

The following sample generates C2144, and shows a way to fix it:
The following example generates C2144, and shows a way to fix it:

```cpp
// C2144.cpp
Expand All @@ -33,7 +34,7 @@ REF struct MyStruct0; // C2144
REF1 MyStruct1;
```

The following sample generates C2144, and shows a way to fix it:
The following example generates C2144, and shows a way to fix it:

```cpp
// C2144_2.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2145.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2145"
title: "Compiler Error C2145"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2145"
ms.date: 11/04/2016
f1_keywords: ["C2145"]
helpviewer_keywords: ["C2145"]
ms.assetid: 158e5809-8adb-4195-8ca5-684501defbc8
---
# Compiler Error C2145

syntax error : missing 'token' before identifier
> syntax error : missing 'token' before identifier

## Remarks

The compiler expected `token` and found identifier instead.

Expand Down
15 changes: 8 additions & 7 deletions docs/error-messages/compiler-errors-1/compiler-error-c2146.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2146"
title: "Compiler Error C2146"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2146"
ms.date: 11/04/2016
f1_keywords: ["C2146"]
helpviewer_keywords: ["C2146"]
ms.assetid: 6bfb7de6-6723-4486-9350-c66ef88d7a64
---
# Compiler Error C2146

syntax error : missing 'token' before identifier 'identifier'
> syntax error : missing 'token' before identifier 'identifier'

## Remarks

The compiler expected `token` and found `identifier` instead. Possible causes:

Expand All @@ -20,7 +21,7 @@ This error may be caused by a typographical error. Error [C2065](../../error-mes

## Examples

The following sample generates C2146.
The following example generates C2146.

```cpp
// C2146.cpp
Expand All @@ -39,7 +40,7 @@ int main() {

This error can also be generated as a result of compiler conformance work that was done for Visual Studio .NET 2003: missing **`typename`** keyword.

The following sample compiles in Visual Studio .NET 2002 but will fail in Visual Studio .NET 2003:
The following example compiles in Visual Studio .NET 2002 but will fail in Visual Studio .NET 2003:

```cpp
// C2146b.cpp
Expand All @@ -64,7 +65,7 @@ You will also see this error as a result of compiler conformance work that was d

The use of `T` from the primary template is not allowed in the explicit specialization. For code to be valid in the Visual Studio .NET 2003 and Visual Studio .NET, replace all instances of the template parameter in the specialization with the explicitly specialized type.

The following sample compiles in Visual Studio .NET but will fail in Visual Studio .NET 2003:
The following example compiles in Visual Studio .NET but will fail in Visual Studio .NET 2003:

```cpp
// C2146_c.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2147.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2147"
title: "Compiler Error C2147"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2147"
ms.date: 11/04/2016
f1_keywords: ["C2147"]
helpviewer_keywords: ["C2147"]
ms.assetid: d1adb3bf-7ece-4815-922c-ad7492fb6670
---
# Compiler Error C2147

syntax error : 'identifier' is a new keyword
> syntax error : 'identifier' is a new keyword

## Remarks

An identifier was used that is now a reserved keyword in the language.

The following sample generates C2147:
## Example

The following example generates C2147:

```cpp
// C2147.cpp
Expand Down
11 changes: 6 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2148.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2148"
title: "Compiler Error C2148"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2148"
ms.date: 11/04/2016
f1_keywords: ["C2148"]
helpviewer_keywords: ["C2148"]
ms.assetid: e510c2c9-7b57-4ce8-be03-ba363e2cc5d9
---
# Compiler Error C2148

total size of array must not exceed 0x7fffffff bytes
> total size of array must not exceed 0x7fffffff bytes

## Remarks

An array exceeds the limit. Reduce the size of the array.

## Example

The following sample generates C2148:
The following example generates C2148:

```cpp
// C2148.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2149.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2149"
title: "Compiler Error C2149"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2149"
ms.date: 11/04/2016
f1_keywords: ["C2149"]
helpviewer_keywords: ["C2149"]
ms.assetid: 7a106dab-d79f-41b9-85be-f36e86e4d2ab
---
# Compiler Error C2149

'identifier' : named bit field cannot have zero width
> 'identifier' : named bit field cannot have zero width

## Remarks

Bit fields can have zero width only if unnamed.

The following sample generates C2149:
## Example

The following example generates C2149:

```cpp
// C2149.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2150.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2150"
title: "Compiler Error C2150"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2150"
ms.date: 11/04/2016
f1_keywords: ["C2150"]
helpviewer_keywords: ["C2150"]
ms.assetid: 21e82a10-c1d4-4c0d-9dc6-c5d92ea42a31
---
# Compiler Error C2150

> '*identifier*' : bit field must have type 'int', 'signed int', or 'unsigned int'

## Remarks

The base type for a bit-field is required to be **`int`**, **`signed int`**, or **`unsigned int`**.

## Example

This sample shows how you might encounter C2150, and how you can fix it:
This example shows how you might encounter C2150, and how you can fix it:

```cpp
// C2150.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2151.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2151"
title: "Compiler Error C2151"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2151"
ms.date: 11/04/2016
f1_keywords: ["C2151"]
helpviewer_keywords: ["C2151"]
ms.assetid: 7f8dd83a-1f41-46d8-8778-0d1f79ed36c9
---
# Compiler Error C2151

more than one language attribute
> more than one language attribute

## Remarks

A function has more than one keyword ( **`__cdecl`**, **`__stdcall`**, or **`__fastcall`**) specifying a calling convention.
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2152.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2152"
title: "Compiler Error C2152"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2152"
ms.date: 11/04/2016
f1_keywords: ["C2152"]
helpviewer_keywords: ["C2152"]
ms.assetid: a9ea2b0c-d55d-41c7-ba9f-dd75592ffc8a
---
# Compiler Error C2152

'identifier' : pointers to functions with different attributes
> 'identifier' : pointers to functions with different attributes

## Remarks

A pointer to a function with one calling convention (**`__cdecl`**, **`__stdcall`**, or **`__fastcall`**) is assigned to a pointer to a function with another calling convention.
10 changes: 7 additions & 3 deletions docs/error-messages/compiler-errors-1/compiler-error-c2153.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
---
title: "Compiler Error C2153"
description: "Learn more about: Compiler Error C2153"
ms.date: "01/31/2025"
ms.date: 01/31/2025
f1_keywords: ["C2153"]
helpviewer_keywords: ["C2153"]
---
# Compiler Error C2153

integer literals must have at least one digit
> integer literals must have at least one digit

## Remarks

Hexadecimal and binary literals must contain at least one digit after the leading sequence (`0x`, `0X`, `0b`, or `0B`), otherwise the trailing character may be incorrectly interpreted as a suffix or literal operator. See [Integer literals](../../cpp/numeric-boolean-and-pointer-literals-cpp.md#integer-literals) for more information.

The following sample generates C2153:
## Example

The following example generates C2153:

```cpp
// C2153.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2154.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2154"
title: "Compiler Error C2154"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2154"
ms.date: 11/04/2016
f1_keywords: ["C2154"]
helpviewer_keywords: ["C2154"]
ms.assetid: 98d6b044-5a3a-43ad-95fa-9b916b22468a
---
# Compiler Error C2154

'type' : only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type'
> 'type' : only enumeration type is allowed as an argument to compiler intrinsic type trait '__underlying_type'

## Remarks

You can only get the underlying type of an enumeration type.

Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2155.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2155"
title: "Compiler Error C2155"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2155"
ms.date: 11/04/2016
f1_keywords: ["C2155"]
helpviewer_keywords: ["C2155"]
ms.assetid: 54d408af-fc48-4121-9011-5e75c7072e01
---
# Compiler Error C2155

'?' : invalid left operand, expected arithmetic or pointer type
> '?' : invalid left operand, expected arithmetic or pointer type

## Remarks

An expression on the left hand side of `?` cannot be compared to zero. You must use an arithmetic or pointer expression that can be compared to zero.
Loading