MISRA.INCL.BADNon-standard include directive. MISRA C 2012 Rule 20.3: The #include directive shall be followed by either a <filename> or "filename" sequenceC90 [Undefined 48], C99 [Undefined 85] Category: Analysis Analysis: Decidable, Single Translation Unit Applies to: C90, C99 AmplificationThis rule applies after macro replacement has been performed. RationaleThe behaviour is undefined if a #include directive does not use one of the following forms:
Example#include "filename.h" /* Compliant */ #include <filename.h> /* Compliant */ #include another.h /* Non-compliant */ #define HEADER "filename.h" #include HEADER /* Compliant */ #define FILENAME file2.h #include FILENAME /* Non-compliant */ #define BASE "base" #define EXT ".ext" #include BASE EXT /* Non-compliant - strings are concatenated * after preprocessing */ #include "./include/cpu.h" /* Compliant - filename may include a path */ MISRA-C 2004 Rule 19.3 (required): The ''#include'' directive shall be followed by either a ''<filename>'' or -'filename''" sequence.Non-standard include directive. [Undefined 48] ExampleFor example, the following are allowed. #include "filename.h" #include <filename.h> #define FILE_A "filename.h" #include FILE_A MISRA-C++ 2008 Rule 16-2-6 (required): The ''#include'' directive shall be followed by either a ''<filename>'' or "filename" sequence.[Undefined 16.2(4)] RationaleThese are the only forms for the #include directive permitted by ISO/IEC 14882:2003 [1]. Example#include "filename.h" // Compliant #include <filename.h> // Compliant #define HEADER "filename.h" // Non-compliant with Rule 16—2—2 #include HEADER // Compliant #include another.h // Non-compliant |