Does extern "C" affect compilation mode

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

 



I'm getting problems with g++ compiling some headers:

#ifdef __cplusplus
extern "C" {
#endif

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

#ifdef __cplusplus
}
#endif

This code compiles with the mbed cloud compiler, Keil RV and VS2010,
but not g++ 4.4.5.  The errors are:

test.cpp:5: error: use of enum ‘abc’ without previous declaration
test.cpp:5: error: invalid type in declaration before ‘;’ token

>From a previous query I understand that the code isn't legal c++, but
is legal c, as demonstrated when I compile the code using the -x c
option.

I'm guessing here, but do some compilers switch into a C compilation
mode when they hit an extern "C"?  I know extern "C" affects the
linkage but is it meant to affect compilation mode?

-- 
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