ports/devel/qt4/files/extrapatch-src-corelib-global-qglobal.h
Raphael Kubo da Costa d4c3da3d2f Use the right macro name when checking whether libc++ is being used.
This fixes a copy-paste error introduced in r397043 ("Update the Qt4 ports to
4.8.7"): libc++ defines _LIBCPP_VERSION, not _LIBCPP_VER (which is defined by a
Dinkumware-based standard library used by QNX). In practice, this meant
Q_COMPILER_INITIALIZER_LISTS was never being enabled with clang.

Submitted by:	Tobias Berner <tcberner@gmail.com>
2016-02-14 13:21:26 +00:00

36 lines
1.6 KiB
C

clang: Only enable Q_COMPILER_INITIALIZER_LISTS with libc++.
This is a workaround for the FreeBSD 9.x series: in Qt 4.8.7, C++11 features
are detected by checking if the compiler supports them. However, initializer
lists support also depends on the C++ standard library. 9.x's libstdc++ from
base (GCC 4.2) does not, so ports with e.g. USES=compiler:c++0x or
compiler:c++11-lang would break: they build with clang and base's libstdc++, so
Qt considers the support is there (including the C++ header) while this is not
the case.
Work around the problem by only enabling Q_COMPILER_INITIALIZER_LISTS if libc++
is being used. Detecting libstdc++'s version is too cumbersome (we would at
least need to include a non-lightweight header such as cstdio to have access to
__GLIBCXX__) and not worth the effort.
--- src/corelib/global/qglobal.h
+++ src/corelib/global/qglobal.h
@@ -854,7 +855,18 @@ namespace QT_NAMESPACE {}
# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
# endif
# if __has_feature(cxx_generalized_initializers)
-# define Q_COMPILER_INITIALIZER_LISTS
+/*
+ * Workaround for FreeBSD 9.x, where we can end up building a port with clang
+ * and base's libstdc++ from GCC 4.2 (which does not support initializer
+ * lists). Since detecting libstdc++'s version is not trivial, only enable the
+ * macro with libc++.
+ */
+# if defined(__cplusplus) /* Only C++ has ciso646. */
+# include <ciso646>
+# if defined(_LIBCPP_VERSION)
+# define Q_COMPILER_INITIALIZER_LISTS
+# endif
+# endif
# endif
# if __has_feature(cxx_lambdas)
# define Q_COMPILER_LAMBDA