If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden
If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hidden.
If a pointer to a structure or union is not dereferenced in a file, the implementation details of the structure or union need not be available in the translation unit for the file. You can hide the implementation details such as structure members and protect them from unintentional changes.
Define an opaque type that can be referenced via pointers but whose contents cannot be accessed.
If a structure or union is defined in a file or a header file included in the file, a pointer to this structure or union declared but the pointer never dereferenced in the file, the checker flags a coding rule violation. The structure or union definition should not be visible to this file.
If you see a violation of this rule on a structure definition, identify if you have defined a pointer to the structure in the same file or in a header file included in the file. Then check if you dereference the pointer anywhere in the file. If you do not dereference the pointer, the structure definition should be hidden from this file and included header files.
If you expect a rule violation but do not see it, refer to the documentation of Polyspace® Code Prover™ or Polyspace Code Prover Server™.
| Group: Code design |
| Category: Advisory |
| AGC Category: Advisory |