An identifier declared in different scopes or multiple times within the same scope can be made to refer to the same object or function by linkage. An identifier can be classified as externally linked, internally linked, or not linked. These three kinds of linkage have the following characteristics [Kirch-Prinz 2002]:
- External linkage. An identifier with external linkage represents the same object or function throughout the entire program, that is, in all compilation units and libraries belonging to the program. The identifier is available to the linker. When a second declaration of the same identifier with external linkage occurs, the linker associates the identifier with the same object or function.
...
Use of an identifier (within one translation unit) classified as both internally and externally linked causes undefined behavior. See also undefined behavior 8 of Appendix J. A translation unit includes the source file together with its headers and all source files included via the preprocessing directive #include
.
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
| 575 S | Fully implemented | |||||||
Splint |
|
|
| ||||||
GCC |
|
|
| ||||||
| IF_DEF_IN_HEADER_DECL IF_MULTI_DECL |
| |||||||
PRQA QA·CQA-C |
| Fully implemented |
...
ISO/IEC 9899:2011 Section 6.2.2, "Linkages of identifiers"
MISRA Rule 8.1
Bibliography
[Banahan 2003] Section 8.2, "Declarations, definitions and accessibility"
[Kirch-Prinz 2002]
...