A potential source of error for C programmers is the inadvertent covering of one header file by another with the same name. This issue is documented by CERT in the "CERT C Secure Coding Standard" as "PRE08-C. Guarantee that header file names are unique [https://www.securecoding.cert.org/confluence/display/seccode/PRE08-C.+Guarantee+that+header+file+names+are+unique]." The risk assessment for this issue is documented as:
"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[https://www.securecoding.cert.org/confluence/display/seccode/PRE08-C.+Guarantee+that+header+file+names+are+unique]." To address this issue it would be a useful feature of the preprocessor to generate a warning when an include directive specifies a header file name which is non-unique within the active header search path. This feature should be an option for the user since implementations for detection of uniqueness would likely incur a performance penalty. It would also be useful to allow the user to specify exceptions for the cases where covering one header with another is intentional. The addition of such a feature to the gcc preprocessor will help programmers mediate the risk of CERT PRE08-C. -- Summary: Detect non-unique header file names. Product: gcc Version: 4.4.2 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: preprocessor AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: don at drexel dot edu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42407