C standard library: standard headers may reserve non-standard identifiers which don't begin with an underscore
Brian Inglis
Brian.Inglis@SystematicSw.ab.ca
Thu Nov 4 17:38:30 GMT 2021
On 2021-11-04 06:40, Corinna Vinschen via Cygwin wrote:
> On Nov 4 00:23, Pavel M via Cygwin wrote:
>> Observation: C standard library: standard headers may reserve non-standard
>> identifiers which don't begin with an underscore.
>>
>> Invocations:
>> $ echo -e "#include <limits.h>\n#define NL_NMAX" | gcc -xc - -std=c11
>> -pedantic -Wall -Wextra -E > /dev/null
>> <stdin>:2: warning: "NL_NMAX" redefined
>> In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/limits.h:203,
>> from
>> /usr/lib/gcc/x86_64-pc-cygwin/11/include/syslimits.h:7,
>> from /usr/lib/gcc/x86_64-pc-cygwin/11/include/limits.h:34,
>> from <stdin>:1:
>> /usr/include/limits.h:507: note: this is the location of the previous
>> definition
>> 507 | #define NL_NMAX INT_MAX
>>
>> $ echo -e "#include <limits.h>\n#define PAGESIZE" | gcc -xc - -std=c11
>> -pedantic -Wall -Wextra -E > /dev/null
>> <stdin>:2: warning: "PAGESIZE" redefined
>> In file included from /usr/lib/gcc/x86_64-pc-cygwin/11/include/limits.h:203,
>> from
>> /usr/lib/gcc/x86_64-pc-cygwin/11/include/syslimits.h:7,
>> from /usr/lib/gcc/x86_64-pc-cygwin/11/include/limits.h:34,
>> from <stdin>:1:
>> /usr/include/limits.h:220: note: this is the location of the previous
>> definition
>> 220 | #define PAGESIZE __PAGESIZE
>>
>> # and so on...
>
> That's ok for limits.h, see
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
>
> Some of the values also use feature test macros.
Most Unix implementations follow POSIX over C and those compilers
default to POSIX and/or GNU over strict C standards.
As they use feature test macros, most/all of these should be suppressed
if your compiler supports -stdXX or equivalent and issue standard
required diagnostics with -pedantic{,-errors} or equivalent.
Library interfaces may also provide means to prefer certain standard
calling sequences over de facto alternatives.
See your compiler and library newlib/libc documentation under Standards
or equivalent e.g
$ info gcc Standards
$ info libc Standards
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
More information about the Cygwin
mailing list