E
Eric Sosman
]
There are many contexts where you're prohibited from defining an
identifier that starts with '_'. This is NOT one of those contexts.
However, can you tell me precisely when it is safe to define such an
identifier? If not, I recommend avoiding them entirely, at least until
you've had time to memorize the relevant rules (section 7.1.3 of the C
standard).I use them in all cases like this, and for global constants. All constants
in my systems are prefixed with an underscore, and are all caps. It's a
convention I picked up from my assembly days and have just kept.
So *all* your constants infringe on reserved name space?
How very jolly ...
Reserved in C/C++. My target is not C/C++, but RDC. It has been my target
since the mid-90s. I just haven't gotten there yet.
Also, the fact that you did things one way in assembly
language -- or in Java or Ada or PL/I or COBOL -- is not a
good reason to do things the same way in C or Lisp or Fortran
or Lua or Perl.
If not ... what is a good reason (given the constraints of: (1) it is
allowed today by the compiler, (2) it does not cause any issue with my
code in source or executable form, (3) my goals are RDC and not C/C++,
and (4) it becomes part of a standard throughout the toolchain
(anything with an underscore and all caps is a constant, and anything
with an underscore indicates it's not the real thing, but a reference
to something else as through a union))?
(1) "Allowed today" does not imply "allowed tomorrow." In
particular, you needn't change the compiler even one little bit
to get into trouble: Just #include a header you didn't use before,
and all of a sudden the fertilizer hits the fan.
(2) If your identifiers conflict with those used by the
implementation, there might be no effect on the executable: If
the source doesn't compile, there's no executable for it to affect.
On the other hand, the source might compile anyhow, but produce
an executable that is defective or behaves in mysterious ways.
(3) Discussing RDC in a C forum makes as much sense as
discussing Algol in an Esperanto forum.
(4) A toolchain that cannot deal properly with the languages
in use is not a tool, just a chain.