Rule 8.8 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.8 Declarations and defnitions (https://forum.misra.org.uk/forumdisplay.php?fid=163) +---- Thread: Rule 8.8 (/showthread.php?tid=1105) |
Rule 8.8 - Akhil - 04-09-2014 1. extern int s=10; 2. static int s; 3. 4. void foo() 5. { 6. /* Do Something*/ 7. } Is line 1 non compliant for Rule 8.8 in the above example. I'm confused since line 1 gives a definition and not just declaration. Here I'm not able to make out whether the var 's' have external or internal linkage. My compiler binds 's' var with extern linkage if a definition is given with extern.(is value is also assigned like the above case). Re: Rule 8.8 - misra-c - 29-09-2014 Code: 1. extern int s=10; However, if the first two lines are switched Code: 1. static int s; Both declarations therefore have internal linkage. This is well-defined in C, but violates rule 8.8. Note: rule 8.8 applies to both definitions and declarations as stated in the Amplification. |