Skip to content

Instantly share code, notes, and snippets.

@chjj
Last active June 25, 2024 09:33
Show Gist options
  • Save chjj/d0c1218e473bbb6d8f9e2224c583e2db to your computer and use it in GitHub Desktop.
Save chjj/d0c1218e473bbb6d8f9e2224c583e2db to your computer and use it in GitHub Desktop.

C Reserved Identifiers

This translates sections 7.1.3 ("Reserved Identifiers") and 7.13 ("Future library directions") of the ISO C90 specification into English (and regexes).

This document will also cover the additions introduced by C99's section 7.26 ("Future library directions"), C11's section 7.31 ("Future library directions"), and C17's section 7.1.3 ("Reserved Identifiers").

We attempt to cover C2x's additions as well. Note that C2x is still unstable and subject to change.

Rules

The ISO C specification describes five different scopes:

  1. File scope
  2. Function scope
  3. Block scope
  4. Function prototype scope
  5. Struct, union, and enum scope

The specification also describes four different namespaces:

  1. Label namespace: labels
  2. Tag namespace: structs, unions, and enums
  3. Member namespace: the members of structs or unions
  4. Ordinary namespace: typedefs, variables, functions, enum constants

Since the label and member namespace are always function and struct/union scoped respectively, we can ignore them for the purposes of this document.

Identifiers collide unacceptably when they have both the same namespace and the same scope. Otherwise, the collision is acceptable. This feature is commonly known as "shadowing".

The rules below may specify a namespace and a scope. Note that macros potentially apply to any namespace/scope as they simply find & replace identifiers.

All rules apply to C90 unless stated otherwise.

  • Reserved identifiers (any scope) & macro names:

    • /^_[A-Z]\w*$/ (exemptions for C17)
    • /^__\w*$/ (exemptions for C17)
    • /^E[0-9A-Z]\w*$/
    • /^LC_[A-Z]\w*$/
    • /^SIG_?[A-Z]\w*$/
    • /^(PRI|SCN)[a-zX]\w*$/ (C99)
    • /^U?INT\w*(_MAX|_MIN|_C)$/ (C99)
    • /^FE_[A-Z]\w*$/ (C11)
    • /^ATOMIC_[A-Z]\w*$/ (C11)
    • /^TIME_[A-Z]\w*$/ (C11)
    • /^U?INT\w*_WIDTH$/ (C2x)
    • /^(FP|MATH)_[A-Z]\w*$/ (C2x)
    • /^(DBL|DEC32|DEC64|DEC128|DEC|FLT|LDBL)_[A-Z]\w*$/ (C2x)
    • Any stdlib macro name (only if included).
  • Reserved ordinary identifiers (file scope):

    • /^_\w*$/
    • /^(is|to)[a-z]\w*$/
    • /^(str|mem|wcs)[a-z]\w*$/
    • /^u?int\w*_t$/ (C99)
    • /^(atomic|memory)_[a-z]\w*$/ (C11)
    • /^memory_order_[a-z]\w*$/ (C11)
    • /^(cnd|mtx|thrd|tss)_\w*$/ (C11)
    • Any stdlib identifier in the ordinary namespace (only if included).
    • Any <math.h> function name suffixed with f or l (C90 only).
    • These <complex.h> function names, or the same name suffixed with f or l (C99/C11/C17 only).
    • These <complex.h> function names, or the same name suffixed with f or l (C2x).
    • These <math.h> function names, or the same name suffixed with f, l, d32, d64, or d128 (C2x).
  • Reserved tag identifiers (file scope):

    • /^_\w*$/
    • Any stdlib identifier in the tag namespace (only if included).
  • Reserved ordinary identifiers with external linkage:

    • Any stdlib identifier (or future-reserved identifier) with external linkage. This includes:
      • errno
      • math_errhandling (C99)
      • setjmp
      • va_copy (C11)
      • va_end
  • C17 exemptions

    • C17 modified some wording to allow ^_[A-Z_] macros to be defined by the programmer when they match an existing keyword. For example: #define _Thread_local __thread is a-okay.
  • C2x redefinition

    • C2x changed some wording to redefine future identifiers as "potentially reserved identifiers". The above identifier patterns which do not currently coincide with existing identifiers provided by the standard library no longer trigger undefined behavior. In other words, after C2x is adopted, this document will no longer be necessary.

C90 <math.h> function names:

  • acos
  • asin
  • atan
  • atan2
  • ceil
  • cos
  • cosh
  • exp
  • fabs
  • floor
  • fmod
  • frexp
  • ldexp
  • log
  • log10
  • modf
  • pow
  • sin
  • sinh
  • sqrt
  • tan
  • tanh

C99/C11/C17 reserved <complex.h> function names:

  • cerf
  • cerfc
  • cexp2
  • cexpm1
  • clog10
  • clog1p
  • clog2
  • clgamma
  • ctgamma

C2x reserved <complex.h> function names:

  • cacospi
  • casinpi
  • catanpi
  • ccompoundn
  • ccospi
  • cerfc
  • cerf
  • cexp10m1
  • cexp10
  • cexp2m1
  • cexp2
  • cexpm1
  • clgamma
  • clog10p1
  • clog10
  • clog1p
  • clog2p1
  • clog2
  • clogp1
  • cpown
  • cpowr
  • crootn
  • crsqrt
  • csinpi
  • ctanpi
  • ctgamma

C2x reserved <math.h> function names:

  • cr_acosh
  • cr_acospi
  • cr_acos
  • cr_asinh
  • cr_asinpi
  • cr_asin
  • cr_atan2pi
  • cr_atan2
  • cr_atanh
  • cr_atanpi
  • cr_atan
  • cr_compoundn
  • cr_cosh
  • cr_cospi
  • cr_cos
  • cr_exp10m1
  • cr_exp10
  • cr_exp2m1
  • cr_exp2
  • cr_expm1
  • cr_exp
  • cr_hypot
  • cr_log10p1
  • cr_log10
  • cr_log1p
  • cr_log2p1
  • cr_log2
  • cr_logp1
  • cr_log
  • cr_pown
  • cr_powr
  • cr_pow
  • cr_rootn
  • cr_rsqrt
  • cr_sinh
  • cr_sinpi
  • cr_sin
  • cr_tanh
  • cr_tanpi
  • cr_tan

What does this mean?

This violates the reserved identifier rules:

static int _foo = 1;

int main(void) {
  return _foo;
}

This does not:

int main(void) {
  static int _foo = 1;
  return _foo;
}

More Examples

It's easy to run into file-scoped identifiers that begin with to, even if you do not mean it as a to[something] conversion function.

Invalid:

static int today = 1;

int main(void) {
  return today;
}

Valid:

int main(void) {
  static int today = 1;
  return today;
}

Likewise, many words begin with str.

Invalid:

static int stream = 1;

int main(void) {
  return stream;
}

Valid:

int main(void) {
  static int stream = 1;
  return stream;
}

Basically any macro that starts with E is a no-no, even if you haven't included <errno.h>.

Invalid:

#define ELEMENT 1

int main(void) {
  return ELEMENT;
}

It seems like it would be easy to avoid collisions with the <signal.h> rule, but there are a number of words that start with "sig". "Sigma" and "signature" are two common ones you might find in programming.

Invalid:

#define SIGMA 1

int main(void) {
  return SIGMA;
}

Double-underscore prefixes are invalid everywhere.

Invalid:

int main(void) {
  int __foo = 1;
  return __foo;
}

An underscore followed by an uppercase letter is invalid everywhere.

Invalid:

int main(void) {
  int _Foo = 1;
  return _Foo;
}

This very commonly used pattern in C programming violates the reserved rules as invalid as _[A-Z] prefixes are invalid everywhere.

Invalid:

#ifndef _MY_HEADER_H
#define _MY_HEADER_H
...
#endif

Valid:

#ifndef MY_HEADER_H
#define MY_HEADER_H
...
#endif

Stdlib identifiers are only invalid if included and used in the same namespace (the tag namespace in this case):

Invalid:

#include <time.h>

union tm {
  int foo;
  char bar;
};

Valid:

#include <time.h>

static int tm(int x, int y) {
  return x + y;
}
[From https://www.pdf-archive.com/2014/10/02/ansi-iso-9899-1990-1/ansi-iso-9899-1990-1.pdf]
[Transcribed by hand -- let me know if there are any typos]
7.1.3 Reserved Identifiers
Each header declares or defines all identifiers listed in its associated
subclause, and optionally declares or defines identifiers listed in its
associated future library directions subclause and identifiers which are always
reserved either for any use or for use as file scope identifiers.
-- All identifiers that begin with an underscore and either an uppercase letter
or another underscore are always reserved for any use.
-- All identifiers that begin with an underscore are always reserved for use as
identifiers with file scope in both the ordinary identifier and tag name
spaces.
-- Each macro name listed in any of the following subclauses (including the
future library directions) is reserved for any use if any of its associated
headers is included.
-- All identifiers with external linkage in any of the following subclauses
(including the future library directions) are always reserved for use as
identifiers with external linkage[90].
-- Each identifier with file scope listed in any of the following subclauses
(including the future library directions) is reserved for use as an
identifier with file scope in the same name space if any of its associated
headers is included.
No other identifiers are reserved. If the program declares or defines an
identifier with the same name as an identifier reserved in that context (other
than as allowed by 7.1.7), the behavior is undefined[91].
[90] The list of reserved identifiers with external linkage includes `errno`,
`setjmp`, and `va_end`.
[91] Since macro names are replaced whenever found, independent of scope and
name space, macro names matching any of the reserved identifiers names
must not be defined if an associated header, if any, is included.
---
7.13 Future library directions
The following names are grouped under individual headers for convenience. All
external names described below are reserved no matter what headers are included
by the program.
7.13.1 Errors `<errno.h>`
Macros that begin with `E` and a digit or `E` and an uppercase letter (followed
by any combinations of digits, letters, and underscore) may be added to the
declarations in the `<errno.h>` header.
7.13.2 Character handling `<ctype.h>`
Function names that begin with either `is` or `to`, and a lowercase letter
(followed by any combination of digits, letters, and underscore) may be added
to the declarations in the `<ctype.h>` header.
7.13.3 Localization `<locale.h>`
Macros that begin with `LC_` and an uppercase letter (followed by any
combination of digits, letters, and underscore) may be added to the definitions
in the `<locale.h>` header.
7.13.4 Mathematics `<math.h>`
The names of all existing functions declared in the `<math.h>` header, suffixed
with `f` or `l` are reserved respectively for corresponding functions with
`float` and `long double` arguments and return values.
7.13.5 Signal handling `<signal.h>`
Macros that begin with either `SIG` and an uppercase letter or `SIG_` and an
uppercase letter (followed by any combination of digits, letters, and
underscore) may be added to the definitions in the `<signal.h>` header.
7.13.6 Input/output `<stdio.h>`
Lowercase letters may be added to the conversion specifiers in `fprintf` and
`fscanf`. Other characters may be used in extensions.
7.13.7 General utilities `<stdlib.h>`
Functions names that begin with `str` and a lowercase letter (followed by any
combination of digits, letters, and underscore) may be added to the
declarations in the `<stdlib.h>` header.
7.13.8 String handling `<string.h>`
Functions names that begin with `str`, `mem`, or `wcs` and a lowercase letter
(followed by any combinations of digits, letters, and underscore) may be added
to the declarations in the `<string.h>` header.
[From https://en.cppreference.com/w/c/language/history]
Neither Technical corrigendum 1 (ISO/IEC 9899:1990/Cor.1:1994), nor Technical
corrigendum 2 (ISO/IEC 9899:1990/Cor.2:1996) modified anything pertaining to
reserved identifiers.
However, C95 (ISO/IEC 9899:1990/Amd.1:1995) added new headers:
- `<iso646.h>`
- `<wchar.h>`
- `<wctype.h>`
Of note is that the last two headers add several `is`, `to`, and `wcs` prefixed
function names.
`<iso646.h>` exposes identifiers which are reserved in C++. See:
https://www.lysator.liu.se/c/iso646.h
Furthermore, digraphs were added:
https://en.wikipedia.org/wiki/Digraph_(computing)#C
[From http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf]
7.1.3 Reserved identifiers
Each header declares or defines all identifiers listed in its associated
subclause, and optionally declares or defines identifiers listed in its
associated future library directions subclause and identifiers which are always
reserved either for any use or for use as file scope identifiers.
-- All identifiers that begin with an underscore and either an uppercase letter
or another underscore are always reserved for any use.
-- All identifiers that begin with an underscore are always reserved for use as
identifiers with file scope in both the ordinary and tag name spaces.
-- Each macro name in any of the following subclauses (including the future
library directions) is reserved for use as specified if any of its
associated headers is included; unless explicitly stated otherwise (see
7.1.4).
-- All identifiers with external linkage in any of the following subclauses
(including the future library directions) are always reserved for use as
identifiers with external linkage[160].
-- Each identifier with file scope listed in any of the following subclauses
(including the future library directions) is reserved for use as a macro
name and as an identifier with file scope in the same name space if any of
its associated headers is included.
No other identifiers are reserved. If the program declares or defines an
identifier in a context in which it is reserved (other than as allowed by
7.1.4), or defines a reserved identifier as a macro name, the behavior is
undefined.
If the program removes (with `#undef`) any macro definition of an identifier in
the first group listed above, the behavior is undefined.
[160] The list of reserved identifiers with external linkage includes `errno`,
`math_errhandling`, `setjmp`, and `va_end`.
---
7.26 Future library directions
The following names are grouped under individual headers for convenience. All
external names described below are reserved no matter what headers are included
by the program.
7.26.1 Complex arithmetic `<complex.h>`
The function names
cerf cexpm1 clog2
cerfc clog10 clgamma
cexp2 clog1p ctgamma
and the same names suffixed with `f` or `l` may be added to the declarations in
the `<complex.h>` header.
7.26.2 Character handling `<ctype.h>`
Function names that begin with either `is` or `to`, and a lowercase letter may
be added to the declarations in the `<ctype.h>` header.
7.26.3 Errors `<errno.h>`
Macros that begin with `E` and a digit or `E` and an uppercase letter may be
added to the declarations in the `<errno.h>` header.
7.26.4 Format conversion of integer types `<inttypes.h>`
Macro names beginning with `PRI` or `SCN` followed by any lowercase letter or
`X` may be added to the macros defined in the `<inttypes.h>` header.
7.26.5 Localization `<locale.h>`
Macros that begin with `LC_` and an uppercase letter may be added to the
definitions in the `<locale.h>` header.
7.26.6 Signal handling `<signal.h>`
Macros that begin with either `SIG` and an uppercase letter or `SIG_` and an
uppercase letter may be added to the definitions in the `<signal.h>` header.
7.26.7 Boolean type and values `<stdbool.h>`
The ability to undefine and perhaps then redefine the macros `bool`, `true`,
and `false` is an obsolescent feature.
7.26.8 Integer types `<stdint.h>`
Typedef names beginning with `int` or `uint` and ending with `_t` may be added
to the types defined in the `<stdint.h>` header. Macro names beginning with
`INT` or `UINT` and ending with `_MAX`, `_MIN`, or `_C` may be added to the
macros defined in the `<stdint.h>` header.
7.26.9 Input/output `<stdio.h>`
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fprintf` and `fscanf`. Other characters may be used in
extensions.
The `gets` function is obsolescent, and is deprecated.
The use of `ungetc` on a binary stream where the file position indicator is
zero prior to the call is an obsolescent feature.
7.26.10 General utilities `<stdlib.h>`
Function names that begin with `str` and a lowercase letter may be added to the
declarations in the `<stdlib.h>` header.
7.26.11 String handling `<string.h>`
Function names that begin with `str`, `mem`, or `wcs` and a lowercase letter
may be added to the declarations in the `<string.h>` header.
7.26.12 Extended multibyte and wide character utilities `<wchar.h>`
Function names that begin with `wcs` and a lowercase letter may be added to the
declarations in the `<wchar.h>` header.
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fwprintf` and `fwscanf`. Other characters may be used in
extensions.
7.26.13 Wide character classification and mapping utilities `<wctype.h>`
Function names that begin with `is` or `to` and a lowercase letter may be added
to the declarations in the `<wctype.h>` header.
[From http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf]
7.1.3 Reserved identifiers
Each header declares or defines all identifiers listed in its associated
subclause, and optionally declares or defines identifiers listed in its
associated future library directions subclause and identifiers which are always
reserved either for any use or for use as file scope identifiers.
-- All identifiers that begin with an underscore and either an uppercase letter
or another underscore are always reserved for any use.
-- All identifiers that begin with an underscore are always reserved for use as
identifiers with file scope in both the ordinary and tag name spaces.
-- Each macro name in any of the following subclauses (including the future
library directions) is reserved for use as specified if any of its
associated headers is included; unless explicitly stated otherwise (see
7.1.4).
-- All identifiers with external linkage in any of the following subclauses
(including the future library directions) and `errno` are always reserved
for use as identifiers with external linkage[184].
-- Each identifier with file scope listed in any of the following subclauses
(including the future library directions) is reserved for use as a macro
name and as an identifier with file scope in the same name space if any of
its associated headers is included.
No other identifiers are reserved. If the program declares or defines an
identifier in a context in which it is reserved (other than as allowed by
7.1.4), or defines a reserved identifier as a macro name, the behavior is
undefined.
If the program removes (with `#undef`) any macro definition of an identifier in
the first group listed above, the behavior is undefined.
[184] The list of reserved identifiers with external linkage includes
`math_errhandling`, `setjmp`, `va_copy`, and `va_end`.
---
7.31 Future library directions
The following names are grouped under individual headers for convenience. All
external names described below are reserved no matter what headers are included
by the program.
7.31.1 Complex arithmetic `<complex.h>`
The function names
cerf cexpm1 clog2
cerfc clog10 clgamma
cexp2 clog1p ctgamma
and the same names suffixed with `f` or `l` may be added to the declarations in
the `<complex.h>` header.
7.31.2 Character handling `<ctype.h>`
Function names that begin with either `is` or `to`, and a lowercase letter may
be added to the declarations in the `<ctype.h>` header.
7.31.3 Errors `<errno.h>`
Macros that begin with `E` and a digit or `E` and an uppercase letter may be
added to the macros defined in the `<errno.h>` header.
7.31.4 Floating-point environment `<fenv.h>`
Macros that begin with `FE_` and an uppercase letter may be added to the macros
defined in the `<fenv.h>` header.
7.31.5 Format conversion of integer types `<inttypes.h>`
Macros that begin with either `PRI` or `SCN`, and either a lowercase letter or
`X` may be added to the macros defined in the `<inttypes.h>` header.
7.31.6 Localization `<locale.h>`
Macros that begin with `LC_` and an uppercase letter may be added to the macros
defined in the `<locale.h>` header.
7.31.7 Signal handling `<signal.h>`
Macros that begin with either `SIG` and an uppercase letter or `SIG_` and an
uppercase letter may be added to the macros defined in the `<signal.h>` header.
7.31.8 Atomics `<stdatomic.h>`
Macros that begin with `ATOMIC_` and an uppercase letter may be added to the
macros defined in the `<stdatomic.h>` header. Typedef names that begin with
either `atomic_` or `memory_`, and a lowercase letter may be added to the
declarations in the `<stdatomic.h>` header. Enumeration constants that begin
with `memory_order_` and a lowercase letter may be added to the definition of
the `memory_order` type in the `<stdatomic.h>` header. Function names that
begin with `atomic_` and a lowercase letter may be added to the declarations in
the `<stdatomic.h>` header.
7.31.9 Boolean type and values `<stdbool.h>`
The ability to undefine and perhaps then redefine the macros `bool`, `true`,
and `false` is an obsolescent feature.
7.31.10 Integer types `<stdint.h>`
Typedef names beginning with `int` or `uint` and ending with `_t` may be added
to the types defined in the `<stdint.h>` header. Macro names beginning with
`INT` or `UINT` and ending with `_MAX`, `_MIN`, or `_C` may be added to the
macros defined in the `<stdint.h>` header.
7.31.11 Input/output `<stdio.h>`
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fprintf` and `fscanf`. Other characters may be used in
extensions.
The use of `ungetc` on a binary stream where the file position indicator is
zero prior to the call is an obsolescent feature.
7.31.12 General utilities `<stdlib.h>`
Function names that begin with `str` and a lowercase letter may be added to the
declarations in the `<stdlib.h>` header.
7.31.13 String handling `<string.h>`
Function names that begin with `str`, `mem`, or `wcs` and a lowercase letter
may be added to the declarations in the `<string.h>` header.
7.31.14 Date and time `<time.h>`
Macros beginning with `TIME_` and an uppercase letter may be added to the
macros in the `<time.h>` header.
7.31.15 Threads `<threads.h>`
Function names, type names, and enumeration constants that begin with either
`cnd_`, `mtx_`, `thrd_`, or `tss_`, and a lowercase letter may be added to the
declarations in the `<threads.h>` header.
7.31.16 Extended multibyte and wide character utilities `<wchar.h>`
Function names that begin with `wcs` and a lowercase letter may be added to the
declarations in the `<wchar.h>` header.
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fwprintf` and `fwscanf`. Other characters may be used in
extensions.
7.31.17 Wide character classification and mapping utilities `<wctype.h>`
Function names that begin with `is` or `to` and a lowercase letter may be added
to the declarations in the `<wctype.h>` header.
[From https://files.lhmouse.com/standards/ISO+C+N2176.pdf]
7.1.3 Reserved identifiers
Each header declares or defines all identifiers listed in its associated
subclause, and optionally declares or defines identifiers listed in its
associated future library directions subclause and identifiers which are always
reserved either for any use or for use as file scope identifiers.
-- All identifiers that begin with an underscore and either an uppercase
letter or another underscore are always reserved for any use, except those
identifiers which are lexically identical to keywords[187].
-- All identifiers that begin with an underscore are always reserved for use as
identifiers with file scope in both the ordinary and tag name spaces.
-- Each macro name in any of the following subclauses (including the future
library directions) is reserved for use as specified if any of its
associated headers is included; unless explicitly stated otherwise (see
7.1.4).
-- All identifiers with external linkage in any of the following subclauses
(including the future library directions) and `errno` are always reserved
for use as identifiers with external linkage[188].
-- Each identifier with file scope listed in any of the following subclauses
(including the future library directions) is reserved for use as a macro
name and as an identifier with file scope in the same name space if any of
its associated headers is included.
No other identifiers are reserved. If the program declares or defines an
identifier in a context in which it is reserved (other than as allowed by
7.1.4), or defines a reserved identifier as a macro name, the behavior is
undefined.
If the program removes (with `#undef`) any macro definition of an identifier in
the first group listed above, the behavior is undefined.
[187] Allows identifiers spelled with a leading underscore followed by an
uppercase letter that match the spelling of a keyword to be used as macro
names by the program.
[188] The list of reserved identifiers with external linkage includes
`math_errhandling`, `setjmp`, `va_copy`, and `va_end`.
---
7.31 Future library directions
The following names are grouped under individual headers for convenience. All
external names described below are reserved no matter what headers are included
by the program.
7.31.1 Complex arithmetic `<complex.h>`
The function names
cerf cexpm1 clog2
cerfc clog10 clgamma
cexp2 clog1p ctgamma
and the same names suffixed with `f` or `l` may be added to the declarations in
the `<complex.h>` header.
7.31.2 Character handling `<ctype.h>`
Function names that begin with either `is` or `to`, and a lowercase letter may
be added to the declarations in the `<ctype.h>` header.
7.31.3 Errors `<errno.h>`
Macros that begin with `E` and a digit or `E` and an uppercase letter may be
added to the macros defined in the `<errno.h>` header.
7.31.4 Floating-point environment `<fenv.h>`
Macros that begin with `FE_` and an uppercase letter may be added to the macros
defined in the `<fenv.h>` header.
7.31.5 Format conversion of integer types `<inttypes.h>`
Macros that begin with either `PRI` or `SCN`, and either a lowercase letter or
`X` may be added to the macros defined in the `<inttypes.h>` header.
7.31.6 Localization `<locale.h>`
Macros that begin with `LC_` and an uppercase letter may be added to the macros
defined in the `<locale.h>` header.
7.31.7 Signal handling `<signal.h>`
Macros that begin with either `SIG` and an uppercase letter or `SIG_` and an
uppercase letter may be added to the macros defined in the `<signal.h>` header.
7.31.8 Atomics `<stdatomic.h>`
Macros that begin with `ATOMIC_` and an uppercase letter may be added to the
macros defined in the `<stdatomic.h>` header. Typedef names that begin with
either `atomic_` or `memory_`, and a lowercase letter may be added to the
declarations in the `<stdatomic.h>` header. Enumeration constants that begin
with `memory_order_` and a lowercase letter may be added to the definition of
the `memory_order` type in the `<stdatomic.h>` header. Function names that
begin with `atomic_` and a lowercase letter may be added to the declarations in
the `<stdatomic.h>` header.
The macro `ATOMIC_VAR_INIT` is an obsolescent feature.
7.31.9 Boolean type and values `<stdbool.h>`
The ability to undefine and perhaps then redefine the macros `bool`, `true`,
and `false` is an obsolescent feature.
7.31.10 Integer types `<stdint.h>`
Typedef names beginning with `int` or `uint` and ending with `_t` may be added
to the types defined in the `<stdint.h>` header. Macro names beginning with
`INT` or `UINT` and ending with `_MAX`, `_MIN`, or `_C` may be added to the
macros defined in the `<stdint.h>` header.
7.31.11 Input/output `<stdio.h>`
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fprintf` and `fscanf`. Other characters may be used in
extensions.
The use of `ungetc` on a binary stream where the file position indicator is
zero prior to the call is an obsolescent feature.
7.31.12 General utilities `<stdlib.h>`
Function names that begin with `str` and a lowercase letter may be added to the
declarations in the `<stdlib.h>` header.
Invoking `realloc` with a size argument equal to zero is an obsolescent
feature.
7.31.13 String handling `<string.h>`
Function names that begin with `str`, `mem`, or `wcs` and a lowercase letter
may be added to the declarations in the `<string.h>` header.
7.31.14 Date and time `<time.h>`
Macros beginning with `TIME_` and an uppercase letter may be added to the
macros in the `<time.h>` header.
7.31.15 Threads `<threads.h>`
Function names, type names, and enumeration constants that begin with either
`cnd_`, `mtx_`, `thrd_`, or `tss_`, and a lowercase letter may be added to the
declarations in the `<threads.h>` header.
7.31.16 Extended multibyte and wide character utilities `<wchar.h>`
Function names that begin with `wcs` and a lowercase letter may be added to the
declarations in the `<wchar.h>` header.
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fwprintf` and `fwscanf`. Other characters may be used in
extensions.
7.31.17 Wide character classification and mapping utilities `<wctype.h>`
Function names that begin with `is` or `to` and a lowercase letter may be added
to the declarations in the `<wctype.h>` header.
[From http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2596.pdf]
7.1.3 Reserved identifiers
Each header declares or defines all identifiers listed in its associated
subclause, and optionally declares or defines identifiers listed in its
associated future library directions subclause and identifiers which are always
reserved either for any use or for use as file scope identifiers.
-- All potentially reserved identifiers (including ones listed in the future
library directions) that are provided by an implementation are reserved for
any use. No other potentially reserved identifiers are reserved[199].
-- Each macro name in any of the following subclauses (including the future
library directions) is reserved for use as specified if any of its
associated headers is included; unless explicitly stated otherwise (see
7.1.4).
-- All identifiers with external linkage in any of the following subclauses
(including the future library directions) and `errno` are always reserved
for use as identifiers with external linkage[200].
-- Each identifier with file scope listed in any of the following subclauses
(including the future library directions) is reserved for use as a macro
name and as an identifier with file scope in the same name space if any of
its associated headers is included.
[199] A potentially reserved identifier becomes a reserved identifier when an
implementation begins using it or a future standard reserves it, but is
otherwise available for use by the programmer.
[200] The list of reserved identifiers with external linkage includes
`math_errhandling`, `setjmp`, `va_copy`, and `va_end`.
---
7.31 Future library directions
The following names are grouped under individual headers for convenience. All
external names described below are reserved no matter what headers are included
by the program.
7.31.1 Complex arithmetic `<complex.h>`
The function names
cacospi cexp10m1 clog10 crootn
casinpi cexp10 clog1p crsqrt
catanpi cexp2m1 clog2p1 csinpi
ccompoundn cexp2 clog2 ctanpi
ccospi cexpm1 clogp1 ctgamma
cerfc clgamma cpown
cerf clog10p1 cpowr
and the same names suffixed with `f` or `l` are potentially reserved identifiers
and may be added to the declarations in the `<complex.h>` header.
7.31.2 Character handling `<ctype.h>`
Function names that begin with either `is` or `to`, and a lowercase letter are
potentially reserved identifiers and may be added to the declarations in the
`<ctype.h>` header.
7.31.3 Errors `<errno.h>`
Macros that begin with `E` and a digit or `E` and an uppercase letter may be
added to the macros defined in the `<errno.h>` header by a future revision of
this document or by an implementation.
7.31.4 Floating-point environment `<fenv.h>`
Macros that begin with `FE_` and an uppercase letter may be added to the macros
defined in the `<fenv.h>` header by a future revision of this document.
7.31.5 Characteristics of floating types `<float.h>`
Macros that begin with `DBL_`, `DEC32_`, `DEC64_`, `DEC128_`, `DEC_`, `FLT_`,
or `LDBL_` and an uppercase letter are potentially reserved identifiers and may
be added to the macros defined in the `<float.h>` header.
7.31.6 Format conversion of integer types `<inttypes.h>`
Macros that begin with either `PRI` or `SCN`, and either a lowercase letter or
`X` are potentially reserved identifiers and may be added to the macros defined
in the `<inttypes.h>` header.
Function names that begin with `str`, or `wcs` and a lowercase letter are
potentially reserved identifiers may be added to the declarations in the
`<inttypes.h>` header.
7.31.7 Localization `<locale.h>`
Macros that begin with `LC_` and an uppercase letter may be added to the macros
defined in the `<locale.h>` header by a future revision of this document or by
an implementation.
7.31.8 Mathematics `<math.h>`
Macros that begin with `FP_` or `MATH_` and an uppercase letter may be added to
the macros defined in the `<math.h>` header by a future revision of this
document or by an implementation.
Macros that begin with `MATH_` and an uppercase letter are potentially reserved
identifiers and may be added to the macros in the `<math.h>` header.
Use of the `DECIMAL_DIG` macro is an obsolescent feature. A similar
type-specific macro, such as `LDBL_DECIMAL_DIG`, can be used instead.
Function names that begin with is and a lowercase letter are potentially
reserved identifiers and may be added to the declarations in the `<math.h>`
header.
The function names
cr_acosh cr_atanh cr_exp10 cr_log1p cr_rootn
cr_acospi cr_atanpi cr_exp2m1 cr_log2p1 cr_rsqrt
cr_acos cr_atan cr_exp2 cr_log2 cr_sinh
cr_asinh cr_compoundn cr_expm1 cr_logp1 cr_sinpi
cr_asinpi cr_cosh cr_exp cr_log cr_sin
cr_asin cr_cospi cr_hypot cr_pown cr_tanh
cr_atan2pi cr_cos cr_log10p1 cr_powr cr_tanpi
cr_atan2 cr_exp10m1 cr_log10 cr_pow cr_tan
and the same names suffixed with `f`, `l`, `d32`, `d64`, or `d128` are
potentially reserved identifiers and may be added to the `<math.h>` header. The
`cr_` prefix is intended to indicate a correctly rounded version of the
function.
7.31.9 Signal handling `<signal.h>`
Macros that begin with either `SIG` and an uppercase letter or `SIG_` and an
uppercase letter may be added to the macros defined in the `<signal.h>` header
by a future revision of this document or by an implementation.
7.31.10 Atomics `<stdatomic.h>`
Macros that begin with `ATOMIC_` and an uppercase letter are potentially
reserved identifiers and may be added to the macros defined in the
`<stdatomic.h>` header. Typedef names that begin with either `atomic_` or
`memory_`, and a lowercase letter are potentially reserved identifiers and may
be added to the declarations in the `<stdatomic.h>` header. Enumeration
constants that begin with `memory_order_` and a lowercase letter are
potentially reserved identifiers and may be added to the definition of the
`memory_order` type in the `<stdatomic.h>` header. Function names that begin
with `atomic_` and a lowercase letter are potentially reserved identifiers and
may be added to the declarations in the `<stdatomic.h>` header.
The macro `ATOMIC_VAR_INIT` is an obsolescent feature.
7.31.11 Boolean type and values `<stdbool.h>`
The ability to undefine and perhaps then redefine the macros `bool`, `true`,
and `false` is an obsolescent feature.
7.31.12 Integer types `<stdint.h>`
Typedef names beginning with int or uint and ending with `_t` are potentially
reserved identifiers and may be added to the types defined in the `<stdint.h>`
header. Macro names beginning with `INT` or `UINT` and ending with `_MAX`,
`_MIN`, `_WIDTH`, or `_C` are potentially reserved identifiers and may be added
to the macros defined in the `<stdint.h>` header.
7.31.13 Input/output `<stdio.h>`
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fprintf` and `fscanf`. Other characters may be used in
extensions.
The use of `ungetc` on a binary stream where the file position indicator is
zero prior to the call is an obsolescent feature.
7.31.14 General utilities `<stdlib.h>`
Function names that begin with `str` or `wcs` and a lowercase letter are
potentially reserved identifiers and may be added to the declarations in the
`<stdlib.h>` header.
Invoking `realloc` with a size argument equal to zero is an obsolescent
feature.
7.31.15 String handling `<string.h>`
Function names that begin with `str`, `mem`, or `wcs` and a lowercase letter
are potentially reserved identifiers and may be added to the declarations in
the `<string.h>` header.
7.31.16 Date and time `<time.h>`
Macros beginning with `TIME_` and an uppercase letter may be added to the
macros in the `<time.h>` header by a future revision of this document or by an
implementation.
7.31.17 Threads `<threads.h>`
Function names, type names, and enumeration constants that begin with either
`cnd_`, `mtx_`, `thrd_`, or `tss_`, and a lowercase letter are potentially
reserved identifiers and may be added to the declarations in the `<threads.h>`
header.
7.31.18 Extended multibyte and wide character utilities `<wchar.h>`
Function names that begin with `wcs` and a lowercase letter are potentially
reserved identifiers and may be added to the declarations in the `<wchar.h>`
header.
Lowercase letters may be added to the conversion specifiers and length
modifiers in `fwprintf` and `fwscanf`. Other characters may be used in
extensions.
7.31.19 Wide character classification and mapping utilities `<wctype.h>`
Function names that begin with `is` or `to` and a lowercase letter are
potentially reserved identifiers and may be added to the declarations in the
`<wctype.h>` header.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment