Note that this recommendation does not require that short file names are used, only that the file names are unique.
Non-Compliant Code Example
The following noncompliant code contains references to headers that may exist independently in various environments but can be ambiguously interpreted by a C99-compliant compiler.
library.h may refer to the same file. Also, because only the first eight characters are guaranteed to be significant, it is unclear whether
utilities_physics.h are parsed. Finally, if a file such as
my_libraryOLD.h exists, it may inadvertently be included instead of
This compliant solution avoids the ambiguity by renaming the associated files to be unique under the above constraints.
The only solution for mitigating ambiguity of a file such as
my_libraryOLD.h is to rename old files with either a prefix (that would fall within the first eight characters) or to add an extension (such as
PRE08-EX1: While C99 only requires eight significant characters, most modern systems have long file names, and compilers on such systems can typically differentiate them. Consequently, long file names in headers may be used, provided that all the implementations to which the code is ported can distinguish between these file names.
Failing to guarantee uniqueness of header files may result in the inclusion of an older version of a header file, which may include incorrect macro definitions or obsolete function prototypes or result in other errors that may or may not be detected by the compiler. Portability issues may also stem from the use of header names that are not guaranteed to be unique.
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
\[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] Section 6.10.2, "Source file inclusion" \[[MISRA 04|AA. C References#MISRA 04]\] Rule 19.5