Re: Does GCC assign any type to enums that can be specified in an assignment operator?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Michael,

The type for the enum, as given, will be signed int.

Now if you want the enum to be ambiguous, you can do something like this:

enum { Uno = -1, Dos, Tres = 0x80000000 };

That will cause an ambiguous overload of the signed & unsigned assignment
operators, since the 0x80000000 will be taken to be an unsigned int as per
the standard C/C++ interpretation rules.  (Assuming a 32-bit int platform.)

Is that the situation you are running into?

You can "fix" it by doing:

enum { Uno = -1, Dos, Tres = int(0x80000000) };

--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux