c++ - Is there a way to prevent a header file without header guards from being included at all at compile time? - Stack Overflow

admin2025-01-08  6

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_H
static_assert(false);
#endif

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

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736271047a1493.html

最新回复(0)