Rule 2.4 and forward declarations - 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.2 Unused code (https://forum.misra.org.uk/forumdisplay.php?fid=157) +---- Thread: Rule 2.4 and forward declarations (/showthread.php?tid=1175) |
Rule 2.4 and forward declarations - michael.metivier - 21-04-2015 Would the use of tags for forward declarations be considered a failure of this rule, if used such as Code: struct test; Re: Rule 2.4 and forward declarations - misra-c - 11-05-2015 The use of tag in a typedef is not a violation of rule 2.4, unless the only occurrence of the tag appears in the typedef declaration. Code: struct A { ... }; // compliant Re: Rule 2.4 and forward declarations - michael.metivier - 11-05-2015 Quote:unless the only occurrence of the tag appears in the typedef declaration. That is the primary concern. There are no other uses of "test"; all other references to the structure are through the typedef, test_T. The circular dependency between Callback_T and the structure test complicates these definitions. The example given allows all references to the structure test to be done through the typedef test_T, but is flagged as a violation because test is not used beyond the snippet given. |