From 6791a47c19cb458ed6764402938538d12567597c Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Tue, 9 Jun 2015 19:31:07 +0200 Subject: [PATCH] Hopefully fix the strdup/_strdup issue The problem was related to the fact that, when compiling in C++11 standard mode (--std=c++11), the compiler/library would not let us use the (non-C++11-standard) strdup()/_strdup() functions. However, the C code was not affected (and the cmake function detection function was not affected as well and was detecting the functions as available). We have to compile in C++11-with-extensions mode (--std=gnu++11) in order to get them. --- buildtools/Cmake/Flags.cmake | 8 ++++---- include/xbt/sysdep.h | 10 +--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/buildtools/Cmake/Flags.cmake b/buildtools/Cmake/Flags.cmake index d179a168be..e51d603aa8 100644 --- a/buildtools/Cmake/Flags.cmake +++ b/buildtools/Cmake/Flags.cmake @@ -4,12 +4,12 @@ set(optCFLAGS "") include(CheckCXXCompilerFlag) if(NOT __VISUALC__ AND NOT __BORLANDC__) - CHECK_CXX_COMPILER_FLAG("-std=c++11" HAVE_CXX11) - CHECK_CXX_COMPILER_FLAG("-std=c++0x" HAVE_CXX0X) + CHECK_CXX_COMPILER_FLAG("-std=gnu++11" HAVE_CXX11) + CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" HAVE_CXX0X) if(HAVE_CXX11) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") elseif(HAVE_CXX0X) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") else() message(STATUS "Missing support for C++11.") endif() diff --git a/include/xbt/sysdep.h b/include/xbt/sysdep.h index f464edd0a9..fae839c089 100644 --- a/include/xbt/sysdep.h +++ b/include/xbt/sysdep.h @@ -74,11 +74,7 @@ char *xbt_strdup(const char *s) { char *res = NULL; if (s) { -# if !defined(_XBT_WIN32) res = strdup(s); -# else - res = _strdup(s); -# endif if (!res) xbt_die("memory allocation error (strdup returned NULL)"); } @@ -138,11 +134,7 @@ void *xbt_realloc(void *p, size_t s) return res; } #else /* non __GNUC__ */ -# if !defined(_XBT_WIN32) -# define xbt_strdup(s) strdup(s) -# else -# define xbt_strdup(s) _strdup(s) -# endif +# define xbt_strdup(s) strdup(s) # define xbt_malloc(n) malloc(n) # define xbt_malloc0(n) calloc(n,1) # define xbt_realloc(p,s) realloc(p,s) -- 2.20.1