Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 3-2-4 comparison with MISRA C Rule 8.9
#1
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.
<t></t>
Reply
#2
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.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)