Miscellaneous-FileUsageInconsistencyΒΆ
Do not use a file as primary file and included file
Required inputs: IR
#include target
elsewhere. And a file included with the user-include syntax ("") should
not be included with the system-include syntax (<>) elsewhere.
Use "" to include user headers, and <> to include system
headers.
Bad code (primary file used in include directive):
// file: foo.c
void foo() {}
// file: main.c
#include "foo.c" // ERROR: primary file is used in include directive
int main() {
foo();
}
Bad code (mixed use of user and system includes):
// file: foo.h void foo(); // file: foo.c #include "foo.h" // ERROR: file is included here as user include // file: main.c #include <foo.h> // ERROR: file is included here as system include
Good code:
// file: foo.h
void foo();
// file: foo.c
#include "foo.h" // OK: file is always included as user include
void foo() {}
// file: main.c
#include "foo.h" // OK: file is always included as user include
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
primary_file_system_include |
Primary file also treated as system include. |
None |
False |
primary_file_user_include |
Primary file also treated as user include. |
None |
False |
user_system_include_mismatch |
File is used both as user include and system include. |
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.