rspec/rules/S956/cfamily/rule.adoc

38 lines
1.4 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
The ``++#include++`` directive is a preprocessor directive that tells the compiler to insert the contents of a file in the source code.
However, the standard only allows the ``++#include++`` directive to be followed by angle brackets (`<filename.h>`) or double quotes (`"filename.h"`).
If the ``++#include++`` directive contains macro names, the result of their expansion must also follow this rule:
2022-02-04 17:28:24 +01:00
[source,cpp]
----
#define HEADER "filename.h"
2023-07-20 09:36:46 +02:00
#include HEADER // Compliant
----
The behavior is undefined if neither angle brackets nor double quotes follow the ``++#include++`` directive.
== Resources
2023-07-20 09:36:46 +02:00
=== External coding guidelines
* MISRA C:2004, 19.3 - The #include directive shall be followed by either a <filename> or "filename" sequence.
* MISRA {cpp}:2008, 16-2-6 - The #include directive shall be followed by either a <filename> or "filename" sequence.
* MISRA C:2012, 20.3 - The #include directive shall be followed by either a <filename> or "filename" sequence
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== on 6 Apr 2015, 12:07:15 Evgeny Mandrikov wrote:
\[~ann.campbell.2] implementation seems more complete (SQALE, description) than this spec.
=== on 13 Apr 2015, 19:45:46 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[]