MISRA Discussion Forums
A question for Rule8.3 - 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 Rule8.3 (/showthread.php?tid=1111)



A question for Rule8.3 - nyoshi - 02-10-2014

I have a question for an exception of Rule8.3.

I think that the structure "tab" of the following sample does not have compatibility.
Is this right?

Code:
[test1.c]
struct tab {
   signed char a;
   signed short  b;
};

struct  tab a;

[test2.c]
Code:
struct tab {
   signed char a;
   signed short int  b;
};

extern struct tab a; /* non-compliant - incompatible version */

Best Regards,
nyoshi


Re: A question for Rule8.3 - misra-c - 07-11-2014

The exception to rule 8.3 allows compatible versions of the same basic type to be used interchangeably. This include basic types used within a structure declaration.

"signed short" and "signed short int" are compatible versions of the same basic type, which means the two versions of the "struct tab" are compatible.