C Reserved Identifiers

Table of Contents

SRC: http://web.archive.org/web/20040209031039/http://oakroadsystems.com/tech/c-predef.htm#Notes

First Surprise: They Look Different, But They're the Same

Make sure that any names you define are unique in the first 31 characters for internal names, or 6 characters (upper and lower case not significant) for external names. The standard says (6.1.2/3.1.2) that conforming implementations can consider, for example, external names ABCDEFG and abcdefh to identify the same object or function.

This means that all identifiers which are "the same" as names of library functions under the external-names equivalence are also reserved for use as externals. For example, there is undefined behavior if you name a non-static function or global variable

cleared( ) CallOccasionally( ) reallocation and Stratford( )

These conflict with

clearerr( ) calloc( ) realloc( )

and the reservation of stranything

Though these names are permitted for your use as macros, automatic variables, etc., I suggest that you always remember the possibility of confusing your fellow programmers and stay away from them.

Your compiler may not complain if you violate these constraints. For instance, your compiler may distinguish more than six characters for external names, or it may distinguish upper and lower case. But I think the rules are still worth following, because you never know when you'll have to port code to some other compiler that is not so discriminating, but still conforms to the letter of the standard.

Second Surprise: They Look the Same, But They're Different

(If you're going for maximum safety, ignore this section and just skip to the next section.)

Yes, it's possible to have two different identifiers that are spelled exactly the same. For instance, struct ceil doesn't conflict with the ceil( ) function, even if you've included the math.h header that declares it. And extern int grouping doesn't conflict with grouping, the member of struct lconv defined in locale.h. In fact, you can legally define a different structure of your own with a member called grouping. (It may be confusing to humans, but it's legal.)

There's no conflict because the identifiers in those examples are in different name spaces. The standard lists ( these separate name spaces:

  • label names
  • tags of struct, union, and enum (one combined name space for all the tags)
  • members of struct and union (a separate name space for each struct or union)
  • ordinary identifiers, which I interpret to comprise objects, functions, and typedef names

An identifier in one name space won't conflict with an identically-named identifier in a different name space. (They also won't conflict if their scopes don't overlap, which is why you can name automatic variables in one function without worrying about the names of other functions or their automatic variables.)

Macro names have their own name space, according to ISO 6.8.3/ANSI 3.8.3: "There is one name space for macro names." But of course you must not create a conflict between a macro and an ordinary name.

The Reserved Identifiers

Respect that first entry in the table below: never make up any identifier that starts with an underscore.

(Actually, you can legally use an identifier that starts with an underscore if the second character is a lower-case letter or a digit, and the identifier is used inside a function or a function prototype or as a structure member or label. Easier just not to use leading underscores!)

There are various other table entries with "[any]". For instance, no matter which headers you use, you must never create (7.13/4.13) a non-static function or global variable that starts with the letters is, mem, str, to, or wcs followed by a lower-case letter. Additional classes of identifiers are reserved if you include particular headers, as indicated in the table.

The Table

identifier       context    header     ISO        ANSI

_[any]         (see Groups)           7.1.3
_[_A-Z][any]       all                7.1.3
__DATE__           all     (predef)   6.8.8      3.8.8
__FILE__           all     (predef)   6.8.8      3.8.8
__LINE__           all     (predef)   6.8.8      3.8.8
__STDC__           all     (predef)   6.8.8      3.8.8
__STDC_VERSION__   all     (predef)   NA1
__TIME__           all     (predef)   6.8.8      3.8.8
_IOFBF             H       stdio.h    7.9.1      4.9.1
_IOLBF             H       stdio.h    7.9.1      4.9.1
_IONBF             H       stdio.h    7.9.1      4.9.1
 identifier       context    header     ISO        ANSI

abort              ext     stdlib.h
abs                ext     stdlib.h
acos               ext     math.h
acosf, acosl       ext     (future)   7.13.4     4.13.4
and                H/C++   iso646.h   NA1
and_eq             H/C++   iso646.h   NA1
asctime            ext     time.h
asin               ext     math.h
asinf, asinl       ext     (future)   7.13.4     4.13.4
asm                C++ only
assert             H       assert.h   7.2        4.2
atan               ext     math.h
atanf, atanl       ext     (future)   7.13.4     4.13.4
atan2              ext     math.h
atan2f, atan2l     ext     (future)   7.13.4     4.13.4
atexit             ext     stdlib.h
atof               ext     stdlib.h
atoi               ext     stdlib.h
atol               ext     stdlib.h
auto               all     (keyword)  6.1.1      3.1.1
 identifier       context    header     ISO        ANSI

bitand             H/C++   iso646.h   NA1
bitor              H/C++   iso646.h   NA1
bool               C++ only
break              all     (keyword)  6.1.1      3.1.1
bsearch            ext     stdlib.h
btowc              extW    wchar.h    NA1
BUFSIZ             H       stdio.h    7.9.1      4.9.1
 identifier       context    header     ISO        ANSI

calloc             ext     stdlib.h
case               all     (keyword)  6.1.1      3.1.1
catch              C++ only
ceil               ext     math.h
ceilf, ceill       ext     (future)   7.13.4     4.13.4
char               all     (keyword)  6.1.1      3.1.1
CHAR_BIT           H       limits.h
CHAR_MAX           H       limits.h
CHAR_MIN           H       limits.h
class              C++ only
clearerr           ext     stdio.h
clock              ext     time.h
clock_t (type)     H       time.h     7.12.1     4.12.1
CLOCKS_PER_SEC     H       time.h     7.12.1     4.12.1
compl              H/C++   iso646.h   NA1
const              all     (keyword)  6.1.1      3.1.1
const_cast         C++ only
continue           all     (keyword)  6.1.1      3.1.1
cos                ext     math.h
cosf               ext     (future)   7.13.4     4.13.4
cosh               ext     math.h
coshf, coshl       ext     (future)   7.13.4     4.13.4
cosl               ext     (future)   7.13.4     4.13.4
ctime              ext     time.h
currency_symbol    Hmem    locale.h   7.4        4.4
 identifier       context    header     ISO        ANSI

DBL_DIG            H       float.h
DBL_EPSILON        H       float.h
DBL_MANT_DIG       H       float.h
DBL_MAX            H       float.h
DBL_MAX_10_EXP     H       float.h
DBL_MAX_EXP        H       float.h
DBL_MIN            H       float.h
DBL_MIN_10_EXP     H       float.h
DBL_MIN_EXP        H       float.h
decimal_point      Hmem    locale.h   7.4        4.4
default            all     (keyword)  6.1.1      3.1.1
defined            all     (predef)   6.8.8      3.8.8
delete             C++ only
difftime           ext     time.h
div                ext     stdlib.h
div_t (type)       H       stdlib.h   7.10       4.10
do                 all     (keyword)  6.1.1      3.1.1
double             all     (keyword)  6.1.1      3.1.1
dynamic_cast       C++ only
 identifier       context    header     ISO        ANSI

E[0-9A-Z][any]     H       errno.h    7.13.1     4.13.1
EDOM               H       errno.h    7.1.4      4.1.3
EILSEQ             H       errno.h    NA1
else               all     (keyword)  6.1.1      3.1.1
enum               all     (keyword)  6.1.1      3.1.1
EOF                H       stdio.h    7.9.1      4.9.1
ERANGE             H       errno.h    7.1.4      4.1.3
errno              H       errno.h    7.1.4      4.1.3
exit               ext     stdlib.h
EXIT_FAILURE       H       stdlib.h   7.10       4.10
EXIT_SUCCESS       H       stdlib.h   7.10       4.10
exp                ext     math.h
expf, expl         ext     (future)   7.13.4     4.13.4
explicit           C++ only
export             C++ only
extern             all     (keyword)  6.1.1      3.1.1
 identifier       context    header     ISO        ANSI

fabs               ext     math.h
fabsf, fabsl       ext     (future)   7.13.4     4.13.4
false              C++ only
fclose             ext     stdio.h
feof               ext     stdio.h
ferror             ext     stdio.h
fflush             ext     stdio.h
fgetc              ext     stdio.h
fgetpos            ext     stdio.h
fgets              ext     stdio.h
fgetwc             extW    wchar.h    NA1
fgetws             extW    wchar.h    NA1
FILE (type)        H       stdio.h    7.9.1      4.9.1
FILENAME_MAX       H       stdio.h    7.9.1      4.9.1
float              all     (keyword)  6.1.1      3.1.1
floor              ext     math.h
floorf, floorl     ext     (future)   7.13.4     4.13.4
FLT_DIG            H       float.h
FLT_EPSILON        H       float.h
FLT_MANT_DIG       H       float.h
FLT_MAX            H       float.h
FLT_MAX_10_EXP     H       float.h
FLT_MAX_EXP        H       float.h
FLT_MIN            H       float.h
FLT_MIN_10_EXP     H       float.h
FLT_MIN_EXP        H       float.h
FLT_RADIX          H       float.h
FLT_ROUNDS         H       float.h
fmod               ext     math.h
fmodf, fmodl       ext     (future)   7.13.4     4.13.4
fopen              ext     stdio.h
FOPEN_MAX          H       stdio.h    7.9.1      4.9.1
for                all     (keyword)  6.1.1      3.1.1
fpos_t (type)      H       stdio.h    7.9.1      4.9.1
fprintf            ext     stdio.h
fputc              ext     stdio.h
fputs              ext     stdio.h
fputwc             extW    wchar.h    NA1
fputws             extW    wchar.h    NA1
frac_digits        Hmem    locale.h   7.4        4.4
fread              ext     stdio.h
free               ext     stdlib.h
freopen            ext     stdio.h
frexp              ext     math.h
frexpf, frexpl     ext     (future)   7.13.4     4.13.4
friend             C++ only
fscanf             ext     stdio.h
fseek              ext     stdio.h
fsetpos            ext     stdio.h
ftell              ext     stdio.h
fwide              extW    wchar.h    NA1
fwprintf           extW    wchar.h    NA1
fwrite             ext     stdio.h
fwscanf            extW    wchar.h    NA1
 identifier       context    header     ISO        ANSI

getc               ext     stdio.h
getchar            ext     stdio.h
getenv             ext     stdlib.h
gets               ext     stdio.h
getwc              extW    wchar.h    NA1
getwchar           extW    wchar.h    NA1
gmtime             ext     time.h
goto               all     (keyword)  6.1.1      3.1.1
grouping           Hmem    locale.h   7.4        4.4

HUGE_VAL           H       math.h     7.5        4.5
 identifier       context    header     ISO        ANSI

if                 all     (keyword)  6.1.1      3.1.1
inline             C++ only
int                all     (keyword)  6.1.1      3.1.1
int_curr_symbol    Hmem    locale.h   7.4        4.4
int_frac_digits    Hmem    locale.h   7.4        4.4
INT_MAX            H       limits.h
INT_MIN            H       limits.h
is[a-z][any]       ext     (future)   7.13.2     4.13.2
isalnum            ext     ctype.h
isalpha            ext     ctype.h
iscntrl            ext     ctype.h
isdigit            ext     ctype.h
isgraph            ext     ctype.h
islower            ext     ctype.h
isprint            ext     ctype.h
ispunct            ext     ctype.h
isspace            ext     ctype.h
isupper            ext     ctype.h
iswalnum           extW    wctype.h   NA1
iswalpha           extW    wctype.h   NA1
iswcntrl           extW    wctype.h   NA1
iswctype           extW    wctype.h   NA1
iswdigit           extW    wctype.h   NA1
iswgraph           extW    wctype.h   NA1
iswlower           extW    wctype.h   NA1
iswprint           extW    wctype.h   NA1
iswpunct           extW    wctype.h   NA1
iswspace           extW    wctype.h   NA1
iswupper           extW    wctype.h   NA1
iswxdigit          extW    wctype.h   NA1
isxdigit           ext     ctype.h

jmp_buf (type)     H       setjmp.h   7.6        4.6
 identifier       context    header     ISO        ANSI

L_tmpnam           H       stdio.h    7.9.1      4.9.1
labs               ext     stdlib.h
LC_[A-Z][any]      H       locale.h   7.13.3     4.13.3
LC_ALL             H       locale.h   7.4        4.4
LC_COLLATE         H       locale.h   7.4        4.4
LC_CTYPE           H       locale.h   7.4        4.4
LC_MONETARY        H       locale.h   7.4        4.4
LC_NUMERIC         H       locale.h   7.4        4.4
LC_TIME            H       locale.h   7.4        4.4
lconv (struct)     Htag    locale.h   7.4        4.4
LDBL_DIG           H       float.h
LDBL_EPSILON       H       float.h
LDBL_MANT_DIG      H       float.h
LDBL_MAX           H       float.h
LDBL_MAX_10_EXP    H       float.h
LDBL_MAX_EXP       H       float.h
LDBL_MIN           H       float.h
LDBL_MIN_10_EXP    H       float.h
LDBL_MIN_EXP       H       float.h
ldexp              ext     math.h
ldexpf, ldexpl     ext     (future)   7.13.4     4.13.4
ldiv               ext     stdlib.h
ldiv_t (type)      H       stdlib.h   7.10       4.10
localeconv         ext     locale.h
localtime          ext     time.h
log                ext     math.h
logf, logl         ext     (future)   7.13.4     4.13.4
log10              ext     math.h
log10f, log10l     ext     (future)   7.13.4     4.13.4
long               all     (keyword)  6.1.1      3.1.1
LONG_MAX           H       limits.h
LONG_MIN           H       limits.h
longjmp            ext     setjmp.h
 identifier       context    header     ISO        ANSI

malloc             ext     stdlib.h
MB_CUR_MAX         H       stdlib.h   7.10       4.10
MB_LEN_MAX         H       limits.h
mblen              ext     stdlib.h
mbrlen             extW    wchar.h    NA1
mbrtowc            extW    wchar.h    NA1
mbsinit            extW    wchar.h    NA1
mbsrtowcs          extW    wchar.h    NA1
mbstate_t (type)   H       wchar.h    NA1
mbstowcs           ext     stdlib.h
mbtowc             ext     stdlib.h
mem[a-z][any]      ext     (future)   7.13.8     4.13.8
memchr             ext     string.h
memcmp             ext     string.h
memcpy             ext     string.h
memmove            ext     string.h
memset             ext     string.h
mktime             ext     time.h
modf               ext     math.h
modff, modfl       ext     (future)   7.13.4     4.13.4
mon_decimal_point  Hmem    locale.h   7.4        4.4
mon_grouping       Hmem    locale.h   7.4        4.4
mon_thousands_sep  Hmem    locale.h   7.4        4.4
mutable            C++ only
 identifier       context    header     ISO        ANSI

n_cs_precedes      Hmem    locale.h   7.4        4.4
n_sep_by_space     Hmem    locale.h   7.4        4.4
n_sign_posn        Hmem    locale.h   7.4        4.4
namespace          C++ only
NDEBUG             H       assert.h   7.2        4.2
negative_sign      Hmem    locale.h   7.4        4.4
new                C++ only
not                H/C++   iso646.h   NA1
not_eq             H/C++   iso646.h   NA1
NULL               H       many       many

offsetof           H       stddef.h   7.1.6      4.1.5
operator           C++ only
or                 H/C++   iso646.h   NA1
or_eq              H/C++   iso646.h   NA1
 identifier       context    header     ISO        ANSI

p_cs_precedes      Hmem    locale.h   7.4        4.4
p_sep_by_space     Hmem    locale.h   7.4        4.4
p_sign_posn        Hmem    locale.h   7.4        4.4
perror             ext     stdio.h
positive_sign      Hmem    locale.h   7.4        4.4
pow                ext     math.h
powf, powl         ext     (future)   7.13.4     4.13.4
printf             ext     stdio.h
private            C++ only
protected          C++ only
ptrdiff_t (type)   H       stddef.h   7.1.6      4.1.5
public             C++ only
putc               ext     stdio.h
putchar            ext     stdio.h
puts               ext     stdio.h
putwc              extW    wchar.h    NA1
putwchar           extW    wchar.h    NA1

qsort              ext     stdlib.h
 identifier       context    header     ISO        ANSI

raise              ext     signal.h
rand               ext     stdlib.h
RAND_MAX           H       stdlib.h   7.10       4.10
realloc            ext     stdlib.h
register           all     (keyword)  6.1.1      3.1.1
reinterpret_cast   C++ only
remove             ext     stdio.h
rename             ext     stdio.h
return             all     (keyword)  6.1.1      3.1.1
rewind             ext     stdio.h
 identifier       context    header     ISO        ANSI

scanf              ext     stdio.h
SCHAR_MAX          H       limits.h
SCHAR_MIN          H       limits.h
SEEK_CUR           H       stdio.h    7.9.1      4.9.1
SEEK_END           H       stdio.h    7.9.1      4.9.1
SEEK_SET           H       stdio.h    7.9.1      4.9.1
setbuf             ext     stdio.h
setjmp             H       setjmp.h
setlocale          ext     locale.h
setvbuf            ext     stdio.h
short              all     (keyword)  6.1.1      3.1.1
SHRT_MAX           H       limits.h
SHRT_MIN           H       limits.h
SIG_[A-Z][any]     H       signal.h   7.7        4.7
sig_atomic_t(type) H       signal.h   7.7        4.7
SIG_DFL            H       signal.h   7.7        4.7
SIG_ERR            H       signal.h   7.7        4.7
SIG_IGN            H       signal.h   7.7        4.7
SIG[A-Z][any]      H       signal.h   7.7        4.7
SIGABRT            H       signal.h   7.7        4.7
SIGFPE             H       signal.h   7.7        4.7
SIGILL             H       signal.h   7.7        4.7
SIGINT             H       signal.h   7.7        4.7
signal             ext     signal.h
signed             all     (keyword)  6.1.1      3.1.1
SIGSEGV            H       signal.h   7.7        4.7
SIGTERM            H       signal.h   7.7        4.7
sin                ext     math.h
sinf               ext     (future)   7.13.4     4.13.4
sinh               ext     math.h
sinhf, sinhl       ext     (future)   7.13.4     4.13.4
sinl               ext     (future)   7.13.4     4.13.4
size_t (type)      ext     many       many
sizeof             all     (keyword)  6.1.1      3.1.1
sprintf            ext     stdio.h
sqrt               ext     math.h
sqrtf, sqrtl       ext     (future)   7.13.4     4.13.4
srand              ext     stdlib.h
sscanf             ext     stdio.h
static             all     (keyword)  6.1.1      3.1.1
static_cast        C++ only
stderr             H       stdio.h    7.9.1      4.9.1
stdin              H       stdio.h    7.9.1      4.9.1
stdout             H       stdio.h    7.9.1      4.9.1
str[a-z][any]      ext     (future)   7.13.7     4.13.7
str[a-z][any]      ext     (future)   7.13.8     4.13.8
strcat             ext     string.h
strchr             ext     string.h
strcmp             ext     string.h
strcoll            ext     string.h
strcpy             ext     string.h
strcspn            ext     string.h
strerror           ext     string.h
strftime           ext     time.h
strlen             ext     string.h
strncat            ext     string.h
strncmp            ext     string.h
strncpy            ext     string.h
strpbrk            ext     string.h
strrchr            ext     string.h
strspn             ext     string.h
strstr             ext     string.h
strtod             ext     stdlib.h
strtok             ext     string.h
strtol             ext     stdlib.h
strtoul            ext     stdlib.h
struct             all     (keyword)  6.1.1      3.1.1
strxfrm            ext     string.h
switch             all     (keyword)  6.1.1      3.1.1
swprintf           extW    wchar.h    NA1
swscanf            extW    wchar.h    NA1
system             ext     stdlib.h
 identifier       context    header     ISO        ANSI

tan                ext     math.h
tanf               ext     (future)   7.13.4     4.13.4
tanh               ext     math.h
tanhf, tanhl       ext     (future)   7.13.4     4.13.4
tanl               ext     (future)   7.13.4     4.13.4
template           C++ only
this               C++ only
thousands_sep      Hmem    locale.h   7.4        4.4
throw              C++ only
time               ext     time.h
time_t (type)      H       time.h     7.12.1     4.12.1
tm (struct)        Htag    time.h     7.12.1     4.12.1
tm (struct)        Htag    wchar.h    NA1
tm_hour            Hmem    time.h     7.12.1     4.12.1
tm_isdst           Hmem    time.h     7.12.1     4.12.1
tm_mday            Hmem    time.h     7.12.1     4.12.1
tm_min             Hmem    time.h     7.12.1     4.12.1
tm_mon             Hmem    time.h     7.12.1     4.12.1
tm_sec             Hmem    time.h     7.12.1     4.12.1
tm_wday            Hmem    time.h     7.12.1     4.12.1
tm_yday            Hmem    time.h     7.12.1     4.12.1
tm_year            Hmem    time.h     7.12.1     4.12.1
TMP_MAX            H       stdio.h    7.9.1      4.9.1
tmpfile            ext     stdio.h
tmpnam             ext     stdio.h
to[a-z][any]       ext     (future)   7.13.2     4.13.2
tolower            ext     ctype.h
toupper            ext     ctype.h
towctrans          extW    wctype.h   NA1
towlower           extW    wctype.h   NA1
towupper           extW    wctype.h   NA1
true               C++ only
try                C++ only
typedef            all     (keyword)  6.1.1      3.1.1
typeid             C++ only
typename           C++ only
 identifier       context    header     ISO        ANSI

UCHAR_MAX          H       limits.h
UINT_MAX           H       limits.h
ULONG_MAX          H       limits.h
ungetc             ext     stdio.h
ungetwc            extW    wchar.h    NA1
union              all     (keyword)  6.1.1      3.1.1
unsigned           all     (keyword)  6.1.1      3.1.1
USHRT_MAX          H       limits.h
using              C++ only
 identifier       context    header     ISO        ANSI

va_arg             H       stdarg.h   7.8.1      4.8.1
va_end             H       stdarg.h   7.8.1      4.8.1
va_list (type)     H       stdarg.h   7.8        4.8
va_start           H       stdarg.h   7.8.1      4.8.1
vfprintf           ext     stdio.h
vfwprintf          extW    wchar.h    NA1
virtual            C++ only
void               all     (keyword)  6.1.1      3.1.1
volatile           all     (keyword)  6.1.1      3.1.1
vprintf            ext     stdio.h
vsprintf           ext     stdio.h
vswprintf          extW    wchar.h    NA1
vwprintf           extW    wchar.h    NA1
 identifier       context    header     ISO        ANSI

WCHAR_MAX          H       wchar.h    NA1
WCHAR_MIN          H       wchar.h    NA1
wchar_t (type)     H/C++   stddef.h   7.1.6      4.1.5
wchar_t (type)     H/C++   stdlib.h   7.10       4.10
wchar_t (type)     H/C++   wchar.h    NA1
wcrtomb            extW    wchar.h    NA1
wcs[a-z][any]      ext     (future)   7.13.8     4.13.8
wcs[a-z][any]      extW    wchar.h    NA1
wcscat             extW    wchar.h    NA1
wcschr             extW    wchar.h    NA1
wcscmp             extW    wchar.h    NA1
wcscoll            extW    wchar.h    NA1
wcscpy             extW    wchar.h    NA1
wcscspn            extW    wchar.h    NA1
wcsftime           extW    wchar.h    NA1
wcslen             extW    wchar.h    NA1
wcsncat            extW    wchar.h    NA1
wcsncmp            extW    wchar.h    NA1
wcsncpy            extW    wchar.h    NA1
wcspbrk            extW    wchar.h    NA1
wcsrchr            extW    wchar.h    NA1
wcsrtombs          extW    wchar.h    NA1
wcsspn             extW    wchar.h    NA1
wcsstr             extW    wchar.h    NA1
wcstod             extW    wchar.h    NA1
wcstok             extW    wchar.h    NA1
wcstol             extW    wchar.h    NA1
wcstombs           ext     stdlib.h
wcstoul            extW    wchar.h    NA1
wcsxfrm            extW    wchar.h    NA1
wctob              extW    wchar.h    NA1
wctomb             ext     stdlib.h
wctrans            extW    wctype.h   NA1
wctrans_t (type)   H       wctype.h   NA1
wctype             extW    wctype.h   NA1
wctype_t (type)    H       wctype.h   NA1
WEOF               H       wchar.h    NA1
WEOF               H       wctype.h   NA1
while              all     (keyword)  6.1.1      3.1.1
wint_t (type)      H       wchar.h    NA1
wint_t (type)      H       wctype.h   NA1
wmemchr            extW    wchar.h    NA1
wmemcmp            extW    wchar.h    NA1
wmemcpy            extW    wchar.h    NA1
wmemmove           extW    wchar.h    NA1
wmemset            extW    wchar.h    NA1
wprintf            extW    wchar.h    NA1
wscanf             extW    wchar.h    NA1

xor                H/C++   iso646.h   NA1
xor_eq             H/C++   iso646.h   NA1

Author: Shi Shougang

Created: 2015-03-05 Thu 23:21

Emacs 24.3.1 (Org mode 8.2.10)