ObDisclaimer IANALL: I am not a language lawyer.
The short form of this is that I think ton's usage is fine.
I believe you are taking the standard too restrictively. If a C compiler were permitted to do wacky things to identifiers beginning with underscore, some other language would be needed to write a compliant libc.
Standardese is a very tricky language. It is difficult to sort out whether a requirement burdens the compiler developer or the user. In the draft version of the standard which you cite, I find two specific sections on allowed names for identifiers.
The fundamental one is §6.4.2.1. It says that a C identifier is made up of characters from [0-9_A-Za-z] with the initial character a non-digit from that set. Aside fron sigils, that is just like Perl. There are provisions to extend those names to wide characters. No provision exists in the standard for a compiler to treat differently a name which satisfies the definition of this section.
In the Library definition, §7.1.3 addresses reserved names. It seems to me that this section digests to "If you use my names, you must replicate my behavior". Undefined things happen if you define your own version of, say, malloc without conforming to the standard of behavior for that function. I an pretty sure that this section concerns what a programmer should expect of the language. Parts of it define conventions for identifier names in the library which I think any user library would be will-advised to follow. One of those is that identifiers beginning with a single underscore have file scope. Effectively, they are private methods..
The only other references to reserved identifiers in the draft standard concern keywords and required macros.
I'm pasting the two sections I discuss below. If someone can cite authority to confirm or deny my reading, I'd appreciate a reference.
Update: There is a companion document called Rationale for International Standard - Programming Languages - C. It documents the intent of the standards committee, and indicates that my notions about redefining libc functions were quite wrong. It tends to support wog's view, but I am still a little confused.
After Compline,
Zaxo
6.4.2.1
General
1 Syntax
identifier:
identifier-nondigit
identifier identifier-nondigit
identifier digit
identifier-nondigit:
nondigit
universal-character-name
other implementation-defined characters
nondigit: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
Semantics
2 An identifier is a sequence of nondigit characters (including
the underscore _, the lowercase and uppercase Latin letters,
and other characters) and digits, which designates one or mor
+e
entities as described in 6.2.1. Lowercase and uppercase
letters are distinct. There is no specific limit on the
maximum length of an identifier.
3 Each universal character name in an identifier shall designat
+e
a character whose encoding in ISO/IEC 10646 falls into one
of the ranges specified in annex D.52) The initial character
shall not be a universal character name designating a digit.
An implementation may allow multibyte characters that are not
part of the required source character set to appear in
identifiers; which characters and their correspondence to
universal character names is implementation defined.
4 When preprocessing tokens are c<onverted to tokens during
translation phase 7, if a preprocessing token could be
converted to either a keyword or an identifier, it is
converted to a keyword.
7.1.3 Reserved identifiers
1 Each header declares or defines all identifiers listed in
its associated subclause, and optionally declares or defines
identifiers listed in its associated future library direction
+s
subclause and identifiers which are always reserved either
for any use or for use as file scope identifiers.
- All identifiers that begin with an underscore and
either an uppercase letter or another underscore
are always reserved for any use.
- All identifiers that begin with an underscore are
always reserved for use as identifiers with file
scope in both the ordinary and tag name spaces.
- Each macro name in any of the following subclauses
(including the future library directions) is
reserved for use as specified if any of its
associated headers is included; unless explicitly
stated otherwise (see 7.1.4).
- All identifiers with external linkage in any of the
following subclauses (including the future library
directions) are always reserved for use as
identifiers with external linkage.143)
- Each identifier with file scope listed in any of the
following subclauses (including the future library
directions) is reserved for use as macro and as an
identifier with file scope in the same name space
if any of its associated headers is included.
2 No other identifiers are reserved. If the program declares o
+r
defines an identifier in a context in which it is reserved (o
+ther
than as allowed by 7.1.4), or defines a reserved identifier a
+s a
macro name, the behavior is undefined.
3 If the program removes (with #undef) any macro definition of
+an
identifier in the first group listed above, the behavior is
undefined.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.