Ð
МакÑим Фомин
I want to hide several fields within structure from "client" code. Can
I use following (just example):
- declare struct X { int visible; }; in "export.h" and several
functions, which take struct X as an argument;
- "export.h" is included by client code;
- declare struct X { int visible; int hidden; }; in "private.h";
- "private.h" is included in .c file which contains definitions of
functions which work with struct X
Thus, when mentioned functions process struct X, they may access to
hidden integer, however external code even doesn't suspect that there
is one.
The first issue of this technique is that client code cannot hold
allocation.
I use following (just example):
- declare struct X { int visible; }; in "export.h" and several
functions, which take struct X as an argument;
- "export.h" is included by client code;
- declare struct X { int visible; int hidden; }; in "private.h";
- "private.h" is included in .c file which contains definitions of
functions which work with struct X
Thus, when mentioned functions process struct X, they may access to
hidden integer, however external code even doesn't suspect that there
is one.
The first issue of this technique is that client code cannot hold
allocation.