KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there a way to make enum type to be unsigned? The following code gives me a warning about signed/unsigned comparison. enum EEE { X1 = 1 }; int main() { size_t x = 2; EEE t = X1; if ( t < x ) std::cout << "ok" << std::endl; return 0; } I've tried to force compiler to use unsigned underlying type for enum with the following: enum EEE { X1 = 1, XN = 18446744073709551615LL // I've tried XN = UINT_MAX (in Visual Studio). Same warning. }; But that still gives the warning. Changing constant to UINT_MAX makes it working in GNU C++ as should be according to the standard. Seems to be a bug in VS. Thanks to James for hint.
Tags (comma-separated)
Save Edits
Cancel