Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2004-8.5_b

In this section:
Synopsis

(Required) There shall be no definitions of objects or functions in a header file.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

One or more non-inlined functions are defined in header files. This check is identical to MISRAC++2008-3-1-1_b, MISRAC++2023-6.2.4_b.

Coding standards
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.

MISRA C++ 2023 6.2.4

(Required) A header file shall not contain definitions of functions or objects that are non-inline and have external linkage

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();
}