Re: Fw: Issue: headers may use non-reserved identifiers

Richard Damon <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On 4/20/22 6:11 PM, C Howland wrote:
>> ------------------------------
>> *From:* Newlib on behalf of Pavel M <[email protected]>
>> *Sent:* Wednesday, April 20, 2022 4:35 PM
>> *To:* [email protected] <[email protected]>
>> *Subject:* Issue: headers may use non-reserved identifiers
>>
>>
>> Hi all,
>>
>> Issue: headers may use non-reserved identifiers.
>>
>> Example:
>> #define _reent 0
>> #include <stdio.h>
>>
>> $ gcc t567.c -std=c11
>> t567.c:1:16: error: expected ‘{’ before numeric constant
>>      1 | #define _reent 0
>>        |                ^
>> t567.c:1:16: error: expected ‘{’ before numeric constant
>>      1 | #define _reent 0
>>        |                ^
>> and so on...
>>
>> Per C11 _reent, _on_exit_args, etc. are non-reserved identifiers.
>>
>> Consider fixing.
>>
>> P.S. Good if it leads to compile time errors, not good if it doesn't (wrong
>> translation unit produced => wrong code generated => wrong runtime
>> behavior).
>>
>> --
>> Pavel
>> ------------------------------
>>
>
> No, the headers do not use non-reserved identifiers.  Look at the standard
> again, as the second dash item in section 7.1.3 Reserved Identifiers
> reserves all identifiers that start with underscore.  The example program
> violates the standard.  In short, user programs may not use identifiers
> that start with underscore.  (More precisely there are some very-limited
> cases in which they can, but preprocessor identifiers is not one of them.)

Slight correction, identifies that begin with an underscore and followed 
by a lowercase letter or a number are reserved only at 'file scope' 
level, so user programs CAN use them as local variable names inside some 
scope (at least those that don't match the previous cluase of an 
underscore followed by an uppercase letter or another underscore as 
those are reserved in all conditions).

Now, in the example, the user program used it for a preprocessor symbol 
which conflicts with the reservation for that identifier for the 
implementations use.

-- 
Richard Damon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.