I was just reading C11, 7.1.3 Reserved identifiers, 2, which says:
No other identifiers are reserved.
Here is a quick test:
# gcc on Linux
$ echo -e "#include <time.h>\n#define CLK_TCK" | gcc82 -xc - -std=c11 -pedantic -Wall -Wextra -E > /dev/null
<stdin>:2: warning: "CLK_TCK" redefined
In file included from /usr/local/ossf/glibc-2.25/include/time.h:33,
from <stdin>:1:
/usr/local/ossf/glibc-2.25/include/bits/time.h:41: note: this is the location of the previous definition
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
# gcc on Windows (Cygwin):
$ 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
# msvc
$ echo -e "#include <errno.h>\n#define STRUNCATE" > tmp.c && cl tmp.c /std:c11 /Za
tmp.c(2): warning C4005: 'STRUNCATE': macro redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.20313.0\ucrt\errno.h(81): note: see previous definition of 'STRUNCATE'
The CLK_TCK
, NL_NMAX
, STRUNCATE
, etc. are expected to be available to the end user. Or do I miss something?
Is it acceptable practice to reserve CLK_TCK
, NL_NMAX
, STRUNCATE
, etc.?