What does the C++ macro
__cpluspluscontain and expand to?Does the macro
__cplusplusalways, even in oldest C++ implementation, contain and expand to a numeric value?Is it safe to use
#if __cplusplusor should we use instead of that#ifdef __cplusplus?
Conclusion (added later)
From comments and accepted answer:
__cplusplusexpands to a number representing the standard's version, except pre-standard C++ in the early 90s (which simply expanded to1).Yes, even in oldest C++ implementation (expands to a numeric value).
No,
#ifdefshould be used when header is shared with C-language (because some C-compilers will warn when#ifchecks undefined macro).
__cplusplus, nor shall it define it in any standard header. The C99 standard says essentially the same, in a slightly different section. The C90 standard was silent on the issue.