This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible bug in gcc (Please Help)...


Hi Tom,

You cannot forward declare an enum in C++.

The compiler can use a {signed|unsigned|nonsigned} char, short or int for
it.  But the compiler doesn't know what it is using until it sees the enum's
definition.  If it presumed that an enum was 1 byte, 2 byte, 4 byte,
whatever, you may end up with an unfortunate scenario.

My SAS/C++ compiler allows...

signed short enum Foo { kOne = 1, kTwo, kThree };

(Or was it "enum signed short Foo { ..."?)

...but that's a SAS/C++ idiosyncratic extension to C++.  In that situation,
you could have forward declaration of the enum.

--Eljay



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]