Skip to content

Commit e5cc15f

Browse files
author
Colin Robertson
committed
Remove C4471 implicit type example
1 parent 56b563f commit e5cc15f

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎docs/error-messages/compiler-warnings/compiler-warning-level-4-c4471.md‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,23 @@ enum Example; // C4471
6464
```
6565

6666
## Example
67-
In C++11, you can add an explicit type to an unscoped enumeration and to its forward declaration. We recommend this solution only if complex header inclusion logic prevents use of the definition instead of a forward declaration. You can also specify an explicit type for the forward declaration of an enumeration that is implicitly typed by an initializer. This solution can lead to a maintenance issue: if you change the underlying type used for the enumeration definition, either explicitly or implicitly, you must also change all of the forward declarations to match, or you may have silent errors in your code. You can put the forward declaration into a header file to minimize this issue.
67+
In C++11, you can add an explicit type to an unscoped enumeration and to its forward declaration. We recommend this solution only if complex header inclusion logic prevents use of the definition instead of a forward declaration. This solution can lead to a maintenance issue: if you change the underlying type used for the enumeration definition, you must also change all of the forward declarations to match, or you may have silent errors in your code. You can put the forward declaration into a header file to minimize this issue.
6868

6969
```cpp
7070
// C4471c.cpp
7171
// Client code for enumeration defined in C4471d.cpp
7272
// Compile with: cl /c /w14471 C4471c.cpp C4471d.cpp
73-
enum Example1; // C4471, int assumed
74-
enum Example2; // C4471, int assumed
73+
enum Example; // C4471, int assumed
7574
// To fix, replace the lines above with the forward declarations:
76-
// enum Example1 : unsigned;
77-
// enum Example2 : unsigned;
75+
// enum Example : unsigned;
7876
// ...
7977
```
8078

8179
```cpp
8280
// C4471d.cpp
8381
// Definition for enumeration used in C4471c.cpp
8482
// Compile with: cl /c /w14471 C4471c.cpp C4471d.cpp
85-
enum Example1 : unsigned { item = 0x80000000 }; // explicit type
86-
enum Example2 { item = 0x80000000 }; // implicit unsigned int type
83+
enum Example : unsigned { item = 0x80000000 }; // explicit type
8784
// ...
8885
```
8986

0 commit comments

Comments
 (0)