GeneralPurpose-SpecialCharactersInIncludes¶
Non-standard characters should not occur in header file names in #include directives
Required inputs: IR
#include directives should contain only portable characters.
Non-standard characters like quotes, backslashes, and comment markers can cause portability
issues across different compilers and platforms, and may be misinterpreted by the preprocessor.
Bad code (non-standard characters in include):
#include "my'header.h" // ERROR: single quote not portable #include my_header.h // ERROR: missing quotes/brackets #include "folder\file.h" // ERROR: backslash may not work on all platforms #include "header/*name.h" // ERROR: comment marker in name
Good code (portable include directives):
#include "my_header.h" // OK: standard characters only #include <iostream> // OK: system include #include "folder/file.h" // OK: forward slash for paths #include "config.h" // OK: alphanumeric and underscore
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
nonstandard_include_character |
Non-standard character in #include directive |
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
check_quotation_mark¶
check_quotation_mark : bool = True
".
forbidden¶
forbidden : set[str] = {"'", '/*', '//', '\'}
" will be added for system-includes.