I am trying to find all the places where #include is placed inside an extern C block. Is it possible to verify this with a preprocessor? I would like to add something like this to my header files:
#ifdef EXTERN_C_IS_IN_EFFECT #error File included from extern "C" block! #endif
I am also looking for other ways to fail compilation in such a case, for example. use a special attribute. I am using gcc 4.4.7.
I defined the following macro and then use it in every header that needs protection against being included in an extern C block:
#define ASSERT_NO_EXTERN_C void assert_no_extern_c(int); void assert_no_extern_c(double);
source share