public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Possible bug in gcc (Please Help)...
@ 2002-05-15 11:12 Thomas J Amato
  2002-05-15 11:32 ` John Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas J Amato @ 2002-05-15 11:12 UTC (permalink / raw)
  To: gcc, gcc-help


Hi,

I created a small test case which gets the following error (using 3.0.3 on
Solaris 2.7):

gcc -x c++ -c enum_test.h
enum_test.h:2: use of enum `colors' without previous declaration

<<snip enum_test.h>>

enum colors;

void func1(colors var1);


Is this a bug in gcc? I can forward declare a class, struct, or union but
not an enum. If this is a bug has it been fixed in 3.0.4 or 3.1? Any help
would be great.

Thanks,

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Possible bug in gcc (Please Help)...
  2002-05-15 11:12 Possible bug in gcc (Please Help) Thomas J Amato
@ 2002-05-15 11:32 ` John Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: John Love-Jensen @ 2002-05-15 11:32 UTC (permalink / raw)
  To: Thomas J Amato, gcc, gcc-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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-05-15 18:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-15 11:12 Possible bug in gcc (Please Help) Thomas J Amato
2002-05-15 11:32 ` John Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).