Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2008-3-1-1_b

In this section:
Synopsis

(Required) It shall be possible to include any header file in multiple translation units without violating the One Definition Rule.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Non-inline functions have been defined in header files. This check is identical to MISRAC2004-8.5_b, MISRAC++2023-6.2.4_b.

Coding standards
MISRA C:2004 8.5

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

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