18.1 All structure or union types shall be complete at... - 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: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.18 Structures and Unions (https://forum.misra.org.uk/forumdisplay.php?fid=48) +---- Thread: 18.1 All structure or union types shall be complete at... (/showthread.php?tid=307) |
18.1 All structure or union types shall be complete at... - srogers - 18-09-2006 Quote:18.1 All structure or union types shall be complete at the end of a translation unit. If my interpretation of this rule is correct then it prohibits the use of opaque pointers. (I wish to use these to hide the contents of structures, so that access is only via certain functions.) Was the prohibition of opaque pointer use deliberate? If so what are the concerns? - misra-c - 09-05-2007 It is desirable to allow opaque pointers, and this rule was not intended to prevent their use. In the Guidelines the line \"struct tnode *pt;\" is given as an example of an incomplete type. The supporting comment correctly states that tnode is incomplete at this point, but the pointer pt is in fact complete. The use of a pointer to an incomplete type is allowed. |