That's *not* the best advice
if you need to compile your code with a C++ compiler:
There is actually nothing at all wrong with writing C code to compile
as C++. One of Bjarne Stroustrup's original purposes in the
development was to create a "better C", and from some points of view
he succeeded quite well.
Nevertheless, C code that compiles with a C++ compiler and produces an
executable with identical results limits one to a subset of C (not
just a subset of C++), and a much smaller one than most people
realize.
The biggest problem with your mention of "if you need to compiler your
code with a C++ compiler" is that it is just plain off-topic here.
Just as much off-topic as discussing attempts to write C code to
compile with a FORTRAN or Lisp compiler.
As far as this newsgroup and the C language are concerned, the
existence of the C++ programming language has been recognized since
October 1999 in the current C standard by references in four foot
notes, and foot notes are not normative:
"182) C++ implementations should define these macros only when
__STDC_FORMAT_MACROS is defined before <inttypes.h> is included."
"217) C++ implementations should define these macros only when
__STDC_LIMIT_MACROS is defined before <stdint.h> is included."
"218) C++ implementations should define these macros only when
__STDC_LIMIT_MACROS is defined before <stdint.h> is included."
"220) C++ implementations should define these macros only when
__STDC_CONSTANT_MACROS is defined before <stdint.h> is included."
Sadly, the topic of writing code that executes with the same results
when compiled with both C and C++ compilers if not particularly
welcome in C++ groups either, as there will likely be many responses
along the lines of "use this or that C++ feature instead."
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq