user6795571 user6795571 - 11 months ago 130
C Question

universal preprocessor define for C or C++?

my code can be compiled with C or C++ compilers.
I'd like to know which one is doing the compilation

is there preprocessor define to tell me this ?

Answer Source

The definition is __cplusplus.

#ifdef __cplusplus 
// treated as C++ code
// treated as C code
#endif // __cplusplus