Compiler Warning (level 3) C4341
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 3) C4341

Error Message

'value' : signed value is out of range for enum constant

An enumerated constant exceeds the limit for an int. The value of the invalid constant is undefined. Constants must resolve to integers between –4,294,967,295 and +4,294,967,295 (signed).

Note that this is a level 3 warning under /Ze and a level 1 warning under /Za.

Example

The following sample generates C4341:

// C4341.cpp
// compile with: /WX /W3 /c
enum ELEMENTS {
   Hydrogen = 1,
   Helium,
   Lithium,
   Beryllium,
   Impossibillium = 4294967296   // C4341
   // try the following line instead
   // Impossibillium = 4294967295
};

The following sample shows that C4341 is a level 1 warning under /Za

// C4341b.cpp
// compile with: /W1 /LD /Za
enum ELEMENTS
{
   Hydrogen = 1,
   Helium,
   Lithium,
   Beryllium,
   Impossibillium = 4294967296  // C4341
   // try the following line instead
   // Impossibillium = 4294967295
};
Show:
© 2016 Microsoft