According to the C Standard, section 7.1.3 [ISO/IEC 9899:2011],
- 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.
- All identifiers with external linkage (including future library directions) and
errno
are always reserved for use as identifiers with external linkage.- 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. (Note that the POSIX standard extends the set of identifiers reserved by the C Standard to include an open-ended set of its own. See section 2.2 Compilation environment, "The Compilation Environment," in IEEE Std 1003.1-2008.) The behavior of a program that declares or defines an identifier in a context in which it is reserved, or defines a reserved identifier as a macro name, is undefined. See also undefined behavior 106 in Annex J of the C Standard. Trying to define a reserved identifier can result in its name conflicting with that used in implementation, which may or may not be detected at compile time.
...
a macro definition of
errno
is suppressed in order to access an actual object, or the program defines an identifier with the nameerrno
. [ISO/IEC 9899:2011]
(See undefined behavior 114 of 114 in Annex J.)
The errno
identifier expands to a modifiable lvalue that has type int
but is not necessarily the identifier of an object. It might expand to a modifiable lvalue resulting from a function call, such as *errno()
. It is unspecified whether errno
is a macro or an identifier declared with external linkage. If a macro definition is suppressed to access an actual object, or a program defines an identifier with the name errno
, the behavior is undefined.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL37-C | low | unlikely | low | P3 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
|
|
| |||||||
Compass/ROSE |
|
|
|
Related Guidelines
...
ISO/IEC 9899:2011 Section 7.1.3, "Reserved identifiers"
Bibliography
[IEEE Std 1003.1-2008] | Section 2.2 "The |
---|
...
Compilation Environment" | |
---|---|
[ISO/IEC 9899:2011] | Section 7.1.3, "Reserved Identifiers" |
...