Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 705

Is there a way to prevent a header file without header guards from being included at all at compile time?

$
0
0

I am trying to ban the inclusion of a list of header files from a source file, and thus preventing the dependency on classes defined in those headers.

There are tricks of checking the header guard macros (like the following), but, in my case, the headers to exclude all use #pragma once instead of header guards.

#ifdef A_BANNED_HEADER_FILE_Hstatic_assert(false);#endif

Is there a way to enforce 0 inclusion at compile time?

P.S. For the purpose of avoiding dependency to any class, I could define a class of the same qualified name in the source file and let redefinition error scream at accidental inclusion.


Viewing all articles
Browse latest Browse all 705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>