suppose my program consists of several layers, say, Layer A and Layer B. The file a_foo.c contains my function definitions, the file a_foo.h contains function declarations corresponding to definitions in a_foo.c.
my design is that modules in the same layer(layer A in this case) can invoke functions declared in a_foo.h while Layer B can not invoke though with a_foo.h included.
so how can i achieve that ? Thanks in advance !
You should separate your two layers into two convenience libraries residing in different directories, with only the public header files of each layer in a common include directory.
Thereby, you’ll avoid accidental inclusion of a_foo.h in layer B.
If you need stronger access control, you’ll need system-dependent hackery. However, this is very unnecessary in most contexts.