MISRA Discussion Forums
A Question for a example of Rule8.6 - 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: A Question for a example of Rule8.6 (/showthread.php?tid=1029)



A Question for a example of Rule8.6 - KumikoItoh - 25-02-2014

I have a question for the Rule8.6 exmaple.

Your guideline has a following example.
/* file3.c */
int16_t j; /* Tentative definition */
int16_t j=1; /* Compliant - external definition */

I make the next exapmle.
Is it correct?

/* file3_2.c */
int16_t m=1; /* Compliant - external definition */ ←is it correct?
int16_t m; /* declaration */ ←is it correct?


Best Regards,
Kumiko Itoh


Re: A Question for a example of Rule8.6 - misra-c - 14-03-2014

You are correct. The example on "m" is compliant. Technically "int16_t m;" is a tentative definition that refers to the previous external definition. It is similar to the example "i1" in Example of section 6.9.2 of the C99 standard.