4 ms·
This is also an old trick to test whether your code was compiled as a C++ or not: 2//**/2 == 1) ? "C" : "C++"
by dfranke 17y ago
This is also an old trick to test whether your code was compiled as a C++ or not:
2//**/2
== 1) ? "C" : "C++"
- timf 17y agoIs there a situation where you would need this instead of "#ifdef __cplusplus"? e.g. http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#faq-32.4 http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html#...
- dfranke 17y agoNo. It's just for hack value.
- yason 17y agoThis is fun and has some hack value but I hope nobody ever uses such a kludge in real code. It totally fails with crappy C compilers that decide to feature C++ comments unannounced. IIRC gcc does this unless you give -ansi or -std=c89. And C99 officially supports the // -comments but hasn't got C++ features, of course.