From: Vadim Zeitlin Date: Wed, 7 Dec 2011 00:59:43 +0000 (+0000) Subject: Fix build with Sun CC under Linux. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/eef2e91ffb62bbf3f61b8d9e718022a020cdeaa2?ds=inline Fix build with Sun CC under Linux. We need to explicitly define _GNU_SOURCE when building our code as we use it configure when running the tests and it's not predefined by Sun CC, unlike g++ so we need to add it to CXXFLAGS ourselves. An alternative solution would be to run the tests without _GNU_SOURCE but this would lose too much functionality so it doesn't seem like a good idea. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/configure b/configure index 908181b752..3d5b60d959 100755 --- a/configure +++ b/configure @@ -19588,6 +19588,9 @@ if test "$USE_LINUX" = 1 -o "$USE_GNU" = 1; then #define _GNU_SOURCE 1 _ACEOF + + GNU_SOURCE_FLAG="-D_GNU_SOURCE" + CFLAGS="$GNU_SOURCE_FLAG $CFLAGS" fi if test "x$USE_AIX" = "x1"; then @@ -25604,7 +25607,7 @@ _ACEOF if test "x$SUNCXX" = xyes; then - CXXFLAGS="-features=tmplife $CXXFLAGS" + CXXFLAGS="-features=tmplife $GNU_SOURCE_FLAG $CXXFLAGS" fi if test "x$SUNCC" = xyes; then diff --git a/configure.in b/configure.in index f768cc5fda..e12e81c30b 100644 --- a/configure.in +++ b/configure.in @@ -1390,6 +1390,11 @@ if test "$USE_LINUX" = 1 -o "$USE_GNU" = 1; then dnl succeed, otherwise things like pthread_mutexattr_settype() (and many dnl others) wouldn't be detected. AC_DEFINE(_GNU_SOURCE) + + dnl For non-g++ compilers (including gcc, as mentioned above) we need to + dnl add this flag explicitly when building our own code later too. + GNU_SOURCE_FLAG="-D_GNU_SOURCE" + CFLAGS="$GNU_SOURCE_FLAG $CFLAGS" fi if test "x$USE_AIX" = "x1"; then @@ -1904,7 +1909,7 @@ WX_CPP_EXPLICIT dnl With Sun CC, temporaries have block scope by default. This flag is needed dnl to get the expression scope behaviour that conforms to the standard. if test "x$SUNCXX" = xyes; then - CXXFLAGS="-features=tmplife $CXXFLAGS" + CXXFLAGS="-features=tmplife $GNU_SOURCE_FLAG $CXXFLAGS" fi dnl Sun X11 headers are (still, in 2005!) non-ANSI and the best they could do