Header name contains a character with undefined behavior
ID |
objectivec.correctness.include_path_special_chars |
Severity |
low |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Preprocessor |
Language |
Objective-C |
Description
Reports an #include or #import whose header name contains an apostrophe, a backslash, a double quote, // or an embedded /*. A single / used as a directory separator is not reported.
Rationale
Inside a header name these characters have undefined behavior; the standard leaves each toolchain free to interpret them as it likes. A backslash is the usual offender, carried over from a Windows path, and toolchains disagree on whether it separates directories or starts an escape sequence, so the same source resolves to a different file - or to no file - on a different compiler. // and /* additionally risk being read as the start of a comment.
The following code illustrates the pattern detected by this rule:
// FLAGGED: Header name contains a character with undefined behavior
#include <sys\types.h>