MISRA Discussion Forums

Full Version: 18.1 All structure or union types shall be complete at...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:18.1 All structure or union types shall be complete at the end of a translation unit.
A complete declaration of the structure or union shall be included within any translation unit that refers to that structure.

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?
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.