[Development] __has_include vs GCC

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Wed Feb 8 22:33:25 CET 2017


Il 08/02/2017 20:40, Marc Mutz ha scritto:
> I, however, intended to use the same feature for <string_view> and 
> <experimental/string_view>, which don't seem to have SD-6 feature test 
> macros (or else define them in the header which you're not allowed to 
> include to check), but since we compile qmake only in C++11, not higher, 
> this was greeted with an #error.

Well, it smells that at least under GCC this would be the idiomatic way:

#if __cplusplus > 201103L && __has_include(<experimental/string_view>)
#include <experimental/string_view>
#endif

(And > 201402L, i.e. post C++14, for string_view). Then again, you may
argue that the presence of the header, even in the right C++ version,
will not tell you if there's a #error "unimplemented" in there; this
sounds like a silly game to play against the toolchain.

Of course, MSVC does not bump __cplusplus (still 199711L). So perhaps
those version checks need to become Qt macros?

My 2 c,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170208/5a74f22a/attachment.bin>


More information about the Development mailing list