You can create an assembly configuration for this purpose (Debug, Release, CheckDependencies). An easy way to change this would be to use a preprocessor to enable / exclude inclusions based on the current configuration. using this, you can test and build using debug or release (which contains a larger set of inclusions), and then compile all the configurations before distribution.
for clarification, the conditional inclusion MON_LIBRARY_VALIDATE_DEPENDENCIES should not be used in library headers or sources in a precompiled header only:
// my pch: #include <file1.hpp> #include <file2.hpp> // ... #if !defined(MON_LIBRARY_VALIDATE_DEPENDENCIES) #include <boost/stuff.hpp> // ...
then you must add MON_LIBRARY_VALIDATE_DEPENDENCIES to the list of preprocessor definitions in the CheckDependencies configuration.
in relation to guards: this should not be a problem if you use defenders under normal circumstances - compilers use optimization to detect these cases, which means that in many cases they can avoid opening a file if it was included and protected correctly. in fact, trying to outwit the compiler in this arena can actually slow down the process. I would say just leaving it as typical if your library / dependencies are huge and you really have noticeable problems.
source share