Make #include <header.h> visible only to your own library

Is it possible to hide

#include <header.h>  //from library B

from projects using library A?

I need to include include, because otherwise my library A will not compile, but since this header from another library B, which should not be visible to the main project, the main program tries to find this header.h and the compilation fails.

+3
source share
1 answer

You can put it inside #ifdefand define a symbol only when compiling library A:

#ifdef INCLUDE_FROM_LIBRARY_B
#include <header.h>  //from library B
#endif //INCLUDE_FROM_LIBRARY_B

Update : but probably the best option is @Robinson's suggestion above: do not include it in any header file, only in .cpp files when necessary.

+1

All Articles