MISRAC++2023-6.2.4_b
In this section:
Synopsis
(Required) A header file shall not contain definitions of functions or objects that are non-inline and have external linkage
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Found non inline definition with external linkage This check is identical to MISRAC++2008-3-1-1_b, MISRAC2004-8.5_b.
Coding standards
- MISRA C:2004 8.5
(Required) There shall be no definitions of objects or functions in a header file.
- MISRA C++ 2008 3-1-1
(Required) It shall be possible to include any header file in multiple translation units without violating the One Definition Rule.
Code examples
The following code example fails the check and will give a warning:
#include "definition.h"
/* Contents of definition.h:
void definition(void) {
}
*/
void example(void) {
definition();
}
The following code example passes the check and will not give a warning about this issue:
#include "declaration.h"
/* Contents of declaration.h:
void definition(void);
*/
void example(void) {
definition();
}