MISRA.ONEDEFRULE.VARGlobal variable definition in a header file. MISRA-C Rule 8.5 (required): There shall be no definitions of objects or functions in a header file.This rule is also covered by MISRA.ONEDEFRULE.FUNC. Header files should be used to declare objects, functions, typedefs, and macros. Header files shall not contain or produce definitions of objects or functions (or fragment of functions or objects) that occupy storage. This makes it clear that only C files contain executable source code and that header files only contain declarations. A "header file" is defined as any file that is included via the #include directive, regardless of name or suffix. MISRA-C++ Rule 3-1-1 (required): It shall be possible to include any header file in multiple translation units without violating the One Definition Rule.This rule is also covered by MISRA.ONEDEFRULE.FUNC. RationaleHeader files should be used to declare objects, functions, inline functions, function templates, typedefs, macros, classes, and class templates and shall not contain or produce definitions of objects or functions (or fragment of functions or objects) that occupy storage. A header file is considered to be any file that is included via the #include directive, regardless of name or suffix. Example// a.h void f1 ( ); // Compliant void f2 ( ) { } // Non-compliant inline void f3 ( ) { } // Compliant template <typename T> void f4 ( T ) { } // Compliant int32_t a; // Non-compliant // a.cpp #include "a.h" External Guidance |