To aid code readability, all the #include
directives in a particular code file should be grouped together near the top of the file.
The only items which may precede an #include
in a file are other preprocessor directives or comments.
Additionally, an #include
may appear within an extern "C"
block, this can be used for instance to include a C file from a
C++ file.
Noncompliant code example
#include <h1.h> /* Compliant */
int32_t i;
#include <f2.h> /* Noncompliant */
Compliant solution
#include <h1.h>
#include <f2.h>
extern "C" {
#include <f3.h>
}
int32_t i;