== Why is this an issue?
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 {cpp} file.
=== Noncompliant code example
[source,cpp]
----
#include
/* Compliant */
int32_t i;
#include /* Noncompliant */
----
=== Compliant solution
[source,cpp]
----
#include
#include
extern "C" {
#include
}
int32_t i;
----
== Resources
* MISRA C:2004, 19.1 - #include statements in a file should only be preceded by other preprocessor directives or comments.
* MISRA {cpp}:2008, 16-0-1 - #include directives in a file shall only be preceded by other preprocessor directives or comments.
* MISRA C:2012, 20.1 - #include directives should only be preceded by preprocessor directives or comments
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== on 31 Mar 2015, 19:00:55 Evgeny Mandrikov wrote:
\[~ann.campbell.2] implementation seems more complete (SQALE, description) than this spec.
=== on 13 Apr 2015, 19:35:57 Evgeny Mandrikov wrote:
\[~ann.campbell.2] I'm wondering why blocker, but not active by default? Note that in implementation currently major and active.
endif::env-github,rspecator-view[]