Rule 3-2-4 comparison with MISRA C Rule 8.9 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18) +--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19) +---- Forum: 6.3 Basic concepts (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=132) +---- Thread: Rule 3-2-4 comparison with MISRA C Rule 8.9 (/showthread.php?tid=929) |
Rule 3-2-4 comparison with MISRA C Rule 8.9 - sarkarsaurabh_27 - 03-01-2013 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 - misra cpp - 05-10-2015 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. |