From c3bd5ffdc8a3b459f18ba6e35fca93e29f3b0ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 8 Dec 2019 23:47:10 +0100 Subject: Don't wrap feature detection macros with QT_HAS_FOO() variants Using wrappers for these macros is problematic when for example passing the -frewrite-includes flag to preprocess sources before shipping off to distcc or Icecream. It will also start producing warnings when compilers implement http://eel.is/c++draft/cpp.cond#7.sentence-2. See for example https://reviews.llvm.org/D49091 Both https://clang.llvm.org/docs/LanguageExtensions.html and the SD-6 document at https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations recommend defining '__has_foo(x) 0' as a fallback for compilers without the macros, so that's what we go for. Change-Id: I0298cd3b4a6ff6618821e34642a5ddd6728be767 Reviewed-by: Alex Richardson Reviewed-by: Thiago Macieira --- src/corelib/tools/qalgorithms.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/tools/qalgorithms.h') diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index b01ce0db58..aa79e0d4a9 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -535,7 +535,7 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera # define QT_HAS_BUILTIN_CTZS Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept { -# if QT_HAS_BUILTIN(__builtin_ctzs) +# if __has_builtin(__builtin_ctzs) return __builtin_ctzs(v); # else return __builtin_ctz(v); @@ -544,7 +544,7 @@ Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) noexcept #define QT_HAS_BUILTIN_CLZS Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) noexcept { -# if QT_HAS_BUILTIN(__builtin_clzs) +# if __has_builtin(__builtin_clzs) return __builtin_clzs(v); # else return __builtin_clz(v) - 16U; -- cgit v1.2.3