Preprocessor directive to test if this is C or C++
- by Collin
I'm trying to find a standard macro which will test whether a header file is being compiled as C or as C++. The purpose of this is that the header may be included by either C or C++ code, and must behave slightly differently depending on which. Specifically:
In C, I need this to be the code:
extern size_t insert (const char*);
In C++, I need this to be the code:
extern "C" size_t insert (const char*);
Additionally, is there a way to avoid putting #ifdef's around every declaration in the header?