C standard library: standard headers may reserve non-standard identifiers which don't begin with an underscore
Pavel M
pavel.morozkin@gmail.com
Wed Nov 3 21:23:13 GMT 2021
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...
Here we see that NL_NMAX and PAGESIZE are non-standard identifiers, which
don't begin with an underscore, and which are reserved by standard header
limits.h. As I understand, these identifiers cannot be reserved due to "No
other identifiers are reserved" (C11, 7.1.3 Reserved identifiers, 1). Do I
miss something?
$ gcc --version
gcc (GCC) 11.1.0
$ uname -a
CYGWIN_NT-10.0 xxx 3.2.0(0.340/5/3) 2021-03-29 08:42 x86_64 Cygwin
Extra: compared to Linux:
$ echo -e "#include <limits.h>\n#define NL_NMAX" | gcc -xc - -std=c11
-pedantic -Wall -Wextra -E > /dev/null
<nothing> (expected)
$ echo -e "#include <limits.h>\n#define PAGESIZE" | gcc -xc - -std=c11
-pedantic -Wall -Wextra -E > /dev/null
<nothing> (expected)
$ gcc --version
gcc-8.2 (GCC) 8.2.0
$ uname -a
Linux xxx 4.10.0-27-generic #30~16.04.2-Ubuntu SMP Thu Jun 29 16:07:46 UTC
2017 x86_64 x86_64 x86_64 GNU/Linux
More information about the Cygwin
mailing list