Skip to content

Commit bfa560e

Browse files
authored
Merge pull request #5047 from MicrosoftDocs/FromPublicMasterBranch
Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main)
2 parents 999e7b0 + c192538 commit bfa560e

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

docs/error-messages/compiler-errors-1/compiler-error-c2018.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,21 @@ ms.assetid: 86b54573-dca0-4446-be1a-e3ac489c073b
1111
unknown character 'hexnumber'
1212

1313
The source file contains an unexpected ASCII character, which is identified by its hex number. To resolve the error, remove the character.
14+
15+
The following sample generates C2018:
16+
17+
```cpp
18+
// C2018.cpp
19+
int main() {
20+
@ // C2018
21+
}
22+
```
23+
24+
Possible resolution:
25+
26+
```cpp
27+
// C2018b.cpp
28+
int main() {
29+
30+
}
31+
```

docs/error-messages/compiler-errors-1/compiler-error-c2023.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,22 @@ helpviewer_keywords: ["C2023"]
1212
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.
1313

1414
To resolve this error, make sure all declarations and definitions of the type use the same alignment value.
15+
16+
The following sample generates C2023:
17+
18+
```cpp
19+
// C2023.cpp
20+
class alignas(2) C;
21+
22+
class alignas(4) C {}; // C2023
23+
```
24+
25+
Possible resolution:
26+
27+
```cpp
28+
// C2023b.cpp
29+
// compile with: /c
30+
class alignas(2) C;
31+
32+
class alignas(2) C {};
33+
```

docs/error-messages/compiler-errors-1/compiler-error-c2024.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,22 @@ helpviewer_keywords: ["C2024"]
1212
The compiler found an **`alignas`** specifier applied to a function or other type that can't be aligned.
1313

1414
To resolve this error, remove the **`alignas`** specifier.
15+
16+
The following sample generates C2024:
17+
18+
```cpp
19+
// C2024.cpp
20+
namespace alignas(2) ns { // C2024
21+
void func(alignas(8) int x) {} // C2024
22+
}
23+
```
24+
25+
Possible resolution:
26+
27+
```cpp
28+
// C2024b.cpp
29+
// compile with: /c
30+
namespace ns {
31+
void func(int x) {}
32+
}
33+
```

0 commit comments

Comments
 (0)