[Bug libstdc++/79433] __has_include(<new header>) is true but #include <new header> gives #error when -std=old

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 10 00:02:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79433

--- Comment #18 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've started a discussion about changing the SD-6 recommendations.

One idea that came out of the discussion so far would be to make a GCC-specific
extension to __has_include. If the has-includes-expression finds a file then it
could read the first line of the file to look for something like:

#pragma GCC has_include(constant-expression)

If found, the result of the has-include-expression would be 1 if the
constant-expression is non-zero, and 0 otherwise.

Then we could decorate our C++17 headers with:

#pragma GCC has_include(__cplusplus > 201402L)

and __has_include would magically give the right answer.


More information about the Gcc-bugs mailing list