[snips]
// comments are accepted by most C compilers: microsoft, gcc, IBM,
and almost all main compilers accept them. This feature is really almost
universal by now.
Not universal; no C89/C90 compiler running in conforming mode will accept
them.
What is strange is that all this people that always speak about
"standard C" do not really mean standard C but some other standard
like C95, C89, or maybe even K&R C from 1975???
Any version of ANSI/ISO C _is_ standard C. There are simply newer
standards and older ones. C89 _is_ standard C, just not the _newest_
standard.
It is already 8 years since 1999, and maybe it is time to look around a
bit?
Or you prefer living in the past, as many people here?
Living in the present, more like it.
Yes, fine, C99 is the newest standard and in theory, one should be writing
code to that. Fine, great, feel free.
There is however a simple reality which that ideal overlooks: not all
compilers support C99, and the ones that do support non-overlapping and
frequently incorrectly implemented subsets of C99.
The reality is that if you write code which needs to be run on a variety
of systems, compiled with a variety of compilers, you cannot rely on most
of what C99 brings, because the compilers themselves simply don't support
it well enough to use it.
Thus, you're left with C89. However, C89 says you cannot use // comments,
regardless of whether compiler A or B supports them, because compiler C is
not required to and you have no control over which compiler will be used.
Further, if you do relax your requirements - say by running compilers A
and B in a less strict mode which does allow // comments - you also relax
the restrictions the compilers work under: they are free to add
non-standard enhancements which may have unforeseen impact upon the of the
code.
So basically, your only hope of producing viable code that will compile
and work correctly in the maximal number of conditions is to produce code
which conforms to a standard which is both old enough to be widely
and correctly implemented, and to not abuse that standard by using
features it doesn't have, in the hopes that these features are the only
way in which the compilers alter what they do from what the standard
mandates that they do.
This is not a good way to develop software.
When C99 is as commonly - and correctly - implemented as C89 is, then
you'll see a migration of code to it. Until then, though, a serious
developer has to stick with what actually works; that means C89 and it
means C89 *without* non-conforming extensions such as // comments.
The *paper* standard may be C99. The real-world standard, as defined not
just by what is used, but in fact by what can be used, is still firmly
C89/C90.