T
Tor Rustad
Keith said:Consider programming in C90 and making sure not to accidentally use a
C++ compiler. You can enforce this with:
#ifdef __cplusplus
#error "Use a C compiler, not a C++ compiler"
#endif
That was a bit drastic, the code should compile under both C and C++,
and a C compiler will not detect if reserved C++ keywords are used. To
test this, a C++ compilation is rather useful. IMO, this is better:
#ifndef __STDC__
#warning "Non Standard C compiler used"
#endif
above, can be extended to detect C95 and C99, via __STDC_VERSION__ checks.
For C++ compilation, the C header files need this:
#ifdef __cplusplus
extern "C" {
#endif
...bla. bla...
#ifdef __cplusplus
}
#endif