What would happen if I (somehow) made an enum bigger than unsigned int?
Each item in one is assigned a numerical value, I'm guessing that is unsigned int.
Would it be boring like an error message or fun? Knowing what's allowed with naming the values there is more than enough combinations (even after removing name size limits and names for common other stuff).
Zssffssz
-4
Junior Poster
Recommended Answers
Jump to PostWhat would happen if I (somehow) made an enum bigger than unsigned int?
The compiler will attempt to adjust the underlying type according to the largest enumerator value. As for defining an enumerator value lager than the largest possible integer, good luck trying. ;)
Jump to PostIn Visual Studio you get an error that says "enumeration value is out of 'int' range".
I have not yet tried it with other compilers.In gcc 3.4.6, it gives a Warning:
warning: this decimal constant is unsigned only in ISO C90
...and it will not compile
All 5 Replies
Narue
5,707
Bad Cop
Team Colleague
thines01
401
Postaholic
Team Colleague
Featured Poster
Zssffssz
-4
Junior Poster
thines01
401
Postaholic
Team Colleague
Featured Poster
vijayan121
1,152
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.