#ifdef __cplusplus
// C++ code
#else
// C code
#endif
The structure is this.
My question is, how to actually trigger the #ifdef on?
I mean, in program? What code I write can turn #ifdef on?
For example, in this case.
is that
#define __cplusplus
will turn it on?
Yes, it will “let it on”.
__cplusplusshould be automatically defined by C++ compiler. C++ uses different name mangling and the macro often used to make C headers compatible with C++: