Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Adding an exception for idempotent macro definitions

...

Implementations conforming to C are required to declare errno in <errno.h>, although some historic implementations failed to do so.

Exceptions

DCL37-C-EX1: Provided that a library function can be declared without reference to any type defined in a header, it is permissible to declare that function without including its header provided that declaration is compatible with the standard declaration.

...

Such code is compliant because the declaration matches what stdlib.h would provide and does not redefine the reserved identifier. However, it would not be acceptable to provide a definition for the free() function in this example.

DCL37-C-EX2: For compatibility with other compiler vendors or language standard modes, it is acceptable to create a macro identifier the same as a reserved identifier so long as the behavior is idempotent, as in this example:

Code Block
bgColor#ccccff
langcpp
// Sometimes generated by configuration tools such as autoconf
#define const const
 
// Allowed compilers with semantically equivalent extension behavior
#define inline __inline

Risk Assessment

Using reserved identifiers can lead to incorrect program operation.

...