It is possible to write a function, which, when compiled with a C compiler will return 0, and when compiled with a C++ compiler, will return 1 (the trivial sulution with
I got an inspiration from What breaking changes are introduced in C++11?:
#define u8 "abc" bool isCpp0x() { const std::string s = u8"def"; // Previously "abcdef", now "def" return s == "def"; }
This is based on the new string literals that take precedence over macro expansion.