Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2023-6.2.4_a

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

mediummedium.png
Full description

Found non inline definition with external linkage This check is identical to MISRAC++2008-3-1-1_a, MISRAC2004-8.5_a.

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:

/*
global_def.h contains:
int global_variable;
 */
#include "global_def.h"

The following code example passes the check and will not give a warning about this issue:

/*
global_decl.h contains:
extern int global_variable;
*/
#include "global_decl.h"