If I have an C++ enum:
enum Foo
{
Bar,
Baz,
Bork,
};
How do I tell the compiler to use a uint16_t to actually store the value of the enum?
EDIT: Does GCC support this feature in its implementation of C++11?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot do this in C++98/03. C++11 does allow you to do it, and without
enum classthe way everyone else seems to keep telling you:Again, you don’t have to use
enum class. Not that it’s a bad idea, but you don’t have to.Which version of GCC? It looks like GCC 4.4 added this functionality, but you should probably look to more recent versions, just for the sake of stability.