[Development] __has_include vs GCC
Marc Mutz
marc.mutz at kdab.com
Thu Feb 9 09:04:51 CET 2017
Hi Steve,
On Thursday 09 February 2017 00:52:03 Stephen Kelly wrote:
> In my opinion, the problem is sd-6 defining feature macros in the header
> that contains the implementation, instead of in a single header.
Indeed, this would have been a valid _other_ way to do things:
#include <cstddef> // contains all the __cpp_* macros, too
#ifdef __cpp_lib_string_view
# include <string_view>
// ...
#endif
#ifdef __cpp_lib_experimetal_string_view
# include <experimental/string_view>
// ...
#endif
But the current version of SD-6 chose to use __has_include to check for
headers (implying that they work, cf. <optional> example in
https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-
recommendations), and the __cpp_lib macros only for versioning of headers.
These things are somewhat orthogonal, and I think the ship has sailed for
central macro header approach.
The issue at hand is that GCC squarely fails to conform to SD-6 re:
__has_include. If it was conformant, I couldn't care less about in which
header a __cpp_* macro was defined. I'd just conditionally include all of them
and check macros at the end.
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
More information about the Development
mailing list