I want to force that a certain struct never gets it's fields accessed directly, always using the struct functions.
Example:
struct NoOutsideAccess { int field1;}
struct example {NoOutsideAccess f1;}
NoOutsideAccess noa;
example * ex;
&noa // OK
&ex->noa // OK
noa.field1; // ERROR
ex->f1.field1 // ERROR
I've looked at C parsers and analysis tools but I'm not sure that I can do this with them.
I don't want to change the struct since it's fields will be used directly within other modules. In this case I want some script that would point out where it's being used, so that the modules that aren't supposed to can change it.
But I did found a duplicate, not sure that will match every usage but will give it a shot.