Page 1 of 1

Rule 3-2-4 comparison with MISRA C Rule 8.9

Posted: Thu Jan 03, 2013 6:59 am
by sarkarsaurabh_27
An identifier with external linkage shall have exactly one definition.
The test exemplar provided with MISRA C for rule 8.9 has
// mc2_0809_1.c
int32_t two_different_definitions = 1; /* Not Compliant - two definitions */
// mc2_0809_2.c
int32_t two_different_definitions = 2; /* Not Compliant - two definitions */
// mc2_0809.h
extern int32_t two_different_definitions;

But the example given in the MISRA C++ Guidelines Draft for Rule 3-2-4 is :
// file1.cpp
int32_t i = 0;
// file2.cpp
int32_t i = 1; // Non-compliant

As both the rules are some what same, but the difference in the example given is that in rule 3-2-4 no external linkage is provided. Is it an incomplete example or the rule should show violation without having an extern of the variable.

Re: Rule 3-2-4 comparison with MISRA C Rule 8.9

Posted: Mon Oct 05, 2015 2:38 pm
by misra cpp
There is no difference in the two examples quoted.

All the variables have external linkage as variables always have external linkage, unless explicitly marked as static.