2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2023-10-30 10:33:56 +01:00
|
|
|
The ``++#include++`` directive is a preprocessor directive that tells the compiler to insert the contents of a file in the source code.
|
2021-04-28 18:08:03 +02:00
|
|
|
|
2023-10-30 10:33:56 +01:00
|
|
|
However, the standard only allows the ``++#include++`` directive to be followed by angle brackets (`<filename.h>`) or double quotes (`"filename.h"`).
|
2021-04-28 18:08:03 +02:00
|
|
|
|
2023-10-30 10:33:56 +01:00
|
|
|
If the ``++#include++`` directive contains macro names, the result of their expansion must also follow this rule:
|
2021-04-28 18:08:03 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,cpp]
|
2021-04-28 18:08:03 +02:00
|
|
|
----
|
|
|
|
#define HEADER "filename.h"
|
2023-07-20 09:36:46 +02:00
|
|
|
#include HEADER // Compliant
|
2021-04-28 18:08:03 +02:00
|
|
|
----
|
|
|
|
|
2023-10-30 10:33:56 +01:00
|
|
|
The behavior is undefined if neither angle brackets nor double quotes follow the ``++#include++`` directive.
|
2021-04-28 18:08:03 +02:00
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
== Resources
|
2021-04-28 18:08:03 +02:00
|
|
|
|
2023-07-20 09:36:46 +02:00
|
|
|
=== External coding guidelines
|
|
|
|
|
2021-04-28 18:08:03 +02:00
|
|
|
* 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
|
|
|
|
|
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== 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.
|
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|