liveBook · Manning

Reserved identifier

As explained in Modern C, Third Edition

A reserved identifier is a name that programmers must not use for their own declarations because the C standard reserves it for specified or future library purposes.

A reserved identifier is a name whose meaning is fixed by the C standard or reserved for library, implementation, or future language use. Programs must not redefine such names in their own declarations. section 9.2

A reserved suffix

The optional Annex K bounds-checking interfaces use names such as printf_s. Because identifiers ending in _s are reserved for these interfaces, application code should not create its own functions or declarations with that suffix. section 8.1.4

Common reservation rules include:

  • Names beginning with an underscore followed by another underscore or a capital letter are reserved for language extensions and internal use. section 9.2
  • Names beginning with an underscore are reserved for file-scope identifiers and for enumeration, structure, and union tags. section 9.2
  • Predefined names, including C library functions, identifiers beginning with str or E, and identifiers ending in _t, are reserved in the contexts specified by the standard. section 9.2
  • Keep header-visible identifiers conforming, expose only intended API names, and use unlikely naming prefixes for reusable libraries. section 9.2
#if !__STDC_LIB_EXT1__
# error "This code needs bounds checking interface Annex K"
#endif
#define __STDC_WANT_LIB_EXT1__ 1

#include <stdio.h>

/* Use printf_s from here on. */

This listing shows the feature-test macros required before headers when using the optional Annex K interface, followed by a reserved-suffix function. section 8.1.4

How Modern C, Third Edition covers it

How deep it goes
Defines reservation categories and naming strategies, but does not enumerate the complete standard namespace.
Examples
Uses printf_s, str-prefixed names, _t suffixes, underscore prefixes, and prefixed library identifiers as naming examples.
What you can do after
Apply naming rules to avoid collisions, limit global exposure, and design safer reusable C interfaces.
How it connects
Connects reserved identifiers with header files, macros, file scope, language extensions, namespaces, and application programming interfaces.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.