This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Does GCC assign any type to enums that can be specified in an assignment operator?
- From: John Love-Jensen <eljay at adobe dot com>
- To: "michael.a" <wild dot eyed dot boy dot from dot freecloud at gmail dot com>, MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Mon, 25 Jun 2007 06:41:27 -0500
- Subject: Re: Does GCC assign any type to enums that can be specified in an assignment operator?
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