Skip to content

Structure error references in range [C2021, C2040] #5522

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: 7 additions & 6 deletions docs/error-messages/compiler-errors-1/compiler-error-c2021.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2021"
title: "Compiler Error C2021"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2021"
ms.date: 11/04/2016
f1_keywords: ["C2021"]
helpviewer_keywords: ["C2021"]
ms.assetid: 064f32e2-3794-48d5-9767-991003dcb36a
---
# Compiler Error C2021

expected exponent value, not 'character'
> expected exponent value, not 'character'

## Remarks

The character used as the exponent of a floating-point constant is not a valid number. Be sure to use an exponent that is in range.

## Examples
## Example

The following sample generates C2021:
The following example generates C2021:

```cpp
// C2021.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2022.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2022"
title: "Compiler Error C2022"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2022"
ms.date: 11/04/2016
f1_keywords: ["C2022"]
helpviewer_keywords: ["C2022"]
ms.assetid: 1f5c477a-d909-42d8-8588-811586e8ba1e
---
# Compiler Error C2022

'number' : too big for character
> 'number' : too big for character

## Remarks

The octal number following a backslash (\\) in a character or string constant is too big to represent a character.
8 changes: 6 additions & 2 deletions docs/error-messages/compiler-errors-1/compiler-error-c2023.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2023"
title: "Compiler Error C2023"
description: "Learn more about: Compiler Error C2023"
ms.date: 08/18/2022
f1_keywords: ["C2023"]
helpviewer_keywords: ["C2023"]
Expand All @@ -9,11 +9,15 @@ helpviewer_keywords: ["C2023"]

> '*identifier*': Alignment (*value-1*) different from prior declaration (*value-2*)

## Remarks

The compiler found an alignment specifier for a class type that's different from a previous declaration, or an **`enum`** alignment specifier that's different from the natural alignment of the base type.

To resolve this error, make sure all declarations and definitions of the type use the same alignment value.

The following sample generates C2023:
## Example

The following example generates C2023:

```cpp
// C2023.cpp
Expand Down
8 changes: 6 additions & 2 deletions docs/error-messages/compiler-errors-1/compiler-error-c2024.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2024"
title: "Compiler Error C2024"
description: "Learn more about: Compiler Error C2024"
ms.date: 08/18/2022
f1_keywords: ["C2024"]
helpviewer_keywords: ["C2024"]
Expand All @@ -9,11 +9,15 @@ helpviewer_keywords: ["C2024"]

> 'alignas' attribute applies to variables, data members and tag types only

## Remarks

The compiler found an **`alignas`** specifier applied to a function or other type that can't be aligned.

To resolve this error, remove the **`alignas`** specifier.

The following sample generates C2024:
## Example

The following example generates C2024:

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

> invalid or corrupted binary module interface file: '*filename*'

## Remarks

The compiler could not read the specified IFC file.

To resolve this error, rebuild the module interface file.
5 changes: 2 additions & 3 deletions docs/error-messages/compiler-errors-1/compiler-error-c2026.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ description: "Describes Microsoft C/C++ compiler error C2026, its causes and how
ms.date: 09/25/2020
f1_keywords: ["C2026"]
helpviewer_keywords: ["C2026"]
ms.assetid: 8e64b6e1-b967-479b-be97-d12dc4a8e389
---
# Compiler Error C2026

> string too big, trailing characters truncated

The string was longer than the limit of 16380 single-byte characters.

## Remarks

The string was longer than the limit of 16380 single-byte characters.

Before adjacent strings get concatenated, a string can't be longer than 16380 single-byte characters.

A Unicode string of about one half this length would also generate this error.
Expand Down
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-1/compiler-error-c2027.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2027"
title: "Compiler Error C2027"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2027"
ms.date: 11/04/2016
f1_keywords: ["C2027"]
helpviewer_keywords: ["C2027"]
ms.assetid: a39150c0-ec04-45ec-934c-a838bfe76627
---
# Compiler Error C2027

use of undefined type 'type'
> use of undefined type 'type'

## Remarks

A type cannot be used until it is defined. To resolve the error, be sure the type is fully defined before referencing it.

## Examples

The following sample generates C2027.
The following example generates C2027.

```cpp
// C2027.cpp
Expand All @@ -36,7 +37,7 @@ int main() {

It is possible to declare a pointer to a declared but undefined type. But C++ does not allow a reference to an undefined type.

The following sample generates C2027.
The following example generates C2027.

```cpp
// C2027_b.cpp
Expand Down
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2028.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
description: "Learn more about: Compiler Error C2028"
title: "Compiler Error C2028"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2028"
ms.date: 11/04/2016
f1_keywords: ["C2028"]
helpviewer_keywords: ["C2028"]
ms.assetid: 4e92e944-8fce-4443-9baf-4411ad9bde70
---
# Compiler Error C2028

struct/union member must be inside a struct/union
> struct/union member must be inside a struct/union

## Remarks

Structure or union members must be declared within the structure or union.
9 changes: 5 additions & 4 deletions docs/error-messages/compiler-errors-1/compiler-error-c2030.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
description: "Learn more about: Compiler Error C2030"
title: "Compiler Error C2030"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2030"
ms.date: 11/04/2016
f1_keywords: ["C2030"]
helpviewer_keywords: ["C2030"]
ms.assetid: 5806cead-64df-4eff-92de-52c9a3f5ee62
---
# Compiler Error C2030

a destructor with 'protected private' accessibility cannot be a member of a class declared 'sealed'
> a destructor with 'protected private' accessibility cannot be a member of a class declared 'sealed'

## Remarks

A Windows Runtime class declared as **`sealed`** cannot have a protected private destructor. Only public virtual and private non-virtual destructors are allowed on sealed types. For more information, see [Ref classes and structs](../../cppcx/ref-classes-and-structs-c-cx.md).

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2031"
title: "Compiler Error C2031"
description: "Learn more about: Compiler Error C2031"
ms.date: 08/18/2022
f1_keywords: ["C2031"]
helpviewer_keywords: ["C2031"]
Expand All @@ -10,6 +10,8 @@ helpviewer_keywords: ["C2031"]
> a virtual destructor with '*accessibility*' accessibility is not allowed for this type\
> a virtual destructor must have 'public' accessibility

## Remarks

A virtual Windows Runtime class has an access specifier or **`sealed`** specifier that's not allowed for a virtual destructor. For more information, see [Ref classes and structs](../../cppcx/ref-classes-and-structs-c-cx.md).

To fix this error, change the accessibility of the destructor.
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2032.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2032"
title: "Compiler Error C2032"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2032"
ms.date: 11/04/2016
f1_keywords: ["C2032"]
helpviewer_keywords: ["C2032"]
ms.assetid: 625d7c83-70b6-42c2-a558-81fbc0026324
---
# Compiler Error C2032

'identifier' : function cannot be member of struct/union 'structorunion'
> 'identifier' : function cannot be member of struct/union 'structorunion'

## Remarks

The structure or union has a member function, which is allowed in C++ but not in C. To resolve the error, either compile as a C++ program or remove the member function.

The following sample generates C2032:
## Example

The following example generates C2032:

```c
// C2032.c
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2033.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2033"
title: "Compiler Error C2033"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2033"
ms.date: 11/04/2016
f1_keywords: ["C2033"]
helpviewer_keywords: ["C2033"]
ms.assetid: fd5a1637-9db2-4c98-a7cc-b63b39737cd9
---
# Compiler Error C2033

'identifier' : bit field cannot have indirection
> 'identifier' : bit field cannot have indirection

## Remarks

The bit field was declared as a pointer, which is not allowed.

The following sample generates C2033:
## Example

The following example generates C2033:

```cpp
// C2033.cpp
Expand Down
13 changes: 8 additions & 5 deletions docs/error-messages/compiler-errors-1/compiler-error-c2034.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
---
description: "Learn more about: Compiler Error C2034"
title: "Compiler Error C2034"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2034"
ms.date: 11/04/2016
f1_keywords: ["C2034"]
helpviewer_keywords: ["C2034"]
ms.assetid: 953d70fa-bde9-4ce6-a55d-741e7bc63ff4
---
# Compiler Error C2034

'identifier' : type of bit field too small for number of bits
> 'identifier' : type of bit field too small for number of bits

## Remarks

The number of bits in the bit-field declaration exceeds the size of the base type.

The following sample generates C2034:
## Example

The following example generates C2034:

```cpp
// C2034.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2035"
title: "Compiler Error C2035"
description: "Learn more about: Compiler Error C2035"
ms.date: 08/18/2022
f1_keywords: ["C2035"]
helpviewer_keywords: ["C2035"]
Expand All @@ -10,6 +10,8 @@ helpviewer_keywords: ["C2035"]
> a non-virtual destructor with '*accessibility*' accessibility is not allowed for this type\
> a non-virtual destructor must have 'protected private' or 'private' accessibility

## Remarks

A non-virtual Windows Runtime class has an access specifier or **`sealed`** specifier that's not allowed for a non-virtual destructor. For more information, see [Ref classes and structs](../../cppcx/ref-classes-and-structs-c-cx.md).

To fix this error, change the accessibility of the destructor.
13 changes: 7 additions & 6 deletions docs/error-messages/compiler-errors-1/compiler-error-c2036.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
description: "Learn more about: Compiler Error C2036"
title: "Compiler Error C2036"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2036"
ms.date: 11/04/2016
f1_keywords: ["C2036"]
helpviewer_keywords: ["C2036"]
ms.assetid: 895821a9-65d1-44b5-bde1-dae827f3e486
---
# Compiler Error C2036

'identifier' : unknown size
> 'identifier' : unknown size

## Remarks

An operation on `identifier` requires the size of the data object, which cannot be determined.

## Examples

The following sample generates C2036.
The following example generates C2036.

```c
// C2036.c
Expand All @@ -29,7 +30,7 @@ int main() {
}
```

The following sample generates C2036.
The following example generates C2036.

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

> left of '*operator*' specifies undefined struct/union '*type*'

## Remarks

The operand to the left of the member-selection *operator* is not a fully defined class, structure, or union.

This error can be caused by a left operand that is an undefined variable.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: "Learn more about: Compiler Error C2038"
title: "Compiler Error C2038"
description: "Learn more about: Compiler Error C2038"
ms.date: 08/18/2022
f1_keywords: ["C2038"]
helpviewer_keywords: ["C2038"]
Expand All @@ -9,6 +9,8 @@ helpviewer_keywords: ["C2038"]

> the std namespace cannot be inline

## Remarks

The C++ standard does not allow the `std` namespace to be declared `inline`.

To resolve this issue, remove the `inline` specifier.
Loading