Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2012-Rule-8.5_a

In this section:
Synopsis

(Required) An external object or function shall be declared once in one and only one file.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Multiple declarations of the same external object or function were found. This check is identical to MISRAC2004-8.8_a, MISRAC++2008-3-2-3_a.

Coding standards
MISRA C:2004 8.8

(Required) An external object or function shall be declared in one and only one file.

MISRA C:2012 Rule-8.5

(Required) An external object or function shall be declared once in one and only one file

MISRA C++ 2008 3-2-3

(Required) A type, object or function that is used in multiple translation units shall be declared in one and only one file.

Code examples

The following code example fails the check and will give a warning:

#include"example.fail.h"

int x;
extern int x;
extern int x;

extern void fun(void);

void fun(void) {
}

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

#include"example.pass.h"

int x = 1;

void fun(void) {
}