Qt-Generic-DuplicateIncludeGuardΒΆ
Different include files should not use the same include guard
Required inputs: IR
Bad code (duplicate include guards):
// file: foo.h #ifndef FOOBAR_H #define FOOBAR_H void foo(); #endif /* FOOBAR_H */ // file: bar.h #ifndef FOOBAR_H // ERROR: Duplicate include guard. #define FOOBAR_H void bar(); #endif /* FOOBAR_H */ // file: main.c #include "foo.h" #include "bar.h" // ERROR: the contents of bar.h will be ignored
Good code (unique include guards):
// file: foo.h #ifndef FOO_H #define FOO_H void foo(); #endif /* FOO_H */ // file: bar.h #ifndef BAR_H // OK: different include guard than in foo.h #define BAR_H void bar(); #endif /* BAR_H */ // file: main.c #include "foo.h" #include "bar.h" // OK: the contents of bar.h will be included
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
duplicate_include_guard |
Duplicate include guard. |
None |
False |
Options
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.