Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Hopefully fix the strdup/_strdup issue
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 9 Jun 2015 17:31:07 +0000 (19:31 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 9 Jun 2015 21:57:35 +0000 (23:57 +0200)
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
include/xbt/sysdep.h

index d179a16..e51d603 100644 (file)
@@ -4,12 +4,12 @@ set(optCFLAGS "")
 include(CheckCXXCompilerFlag)
 
 if(NOT __VISUALC__ AND NOT __BORLANDC__)
 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)
   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)
   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()
   else()
     message(STATUS "Missing support for C++11.")
   endif()
index f464edd..fae839c 100644 (file)
@@ -74,11 +74,7 @@ char *xbt_strdup(const char *s)
 {
   char *res = NULL;
   if (s) {
 {
   char *res = NULL;
   if (s) {
-# if !defined(_XBT_WIN32)
     res = strdup(s);
     res = strdup(s);
-# else
-    res = _strdup(s);
-# endif
     if (!res)
       xbt_die("memory allocation error (strdup returned NULL)");
   }
     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__  */
   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)
 #  define xbt_malloc(n)    malloc(n)
 #  define xbt_malloc0(n)   calloc(n,1)
 #  define xbt_realloc(p,s) realloc(p,s)