Error when forward referencing an enum in a typedef

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

 



The following code fails to compile on GCC 4.5.1 (CodeSourcery G++
Lite for ARM), whereas it compiles happily under the ARM compiler and
Visual Studio 2010.

#ifdef __cplusplus
extern "C" {
#endif

typedef enum abc xyz;
enum abc {
    p1 = 0,
    p2,
    p3
};

#ifdef __cplusplus
}
#endif

The errors produced are:

test.cpp:5:14: error: use of enum 'abc' without previous declaration
test.cpp:5:21: error: invalid type in declaration before ';' token

Is this a bug, or stricter compliance?  Is there an option to permit
this sort of construct to compile?  I'm aware that putting the typedef
after the enum definition allows it to compile, but this would then
mean modifying the vendor supplied headers and keeping track of
changes would be much more difficult.

--
Regards,

Graham Bloice



[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