strdup() is not standard C/C++. On Windows, noth _strdup() and
_strdup() are available in C. However, strdup() is not available in
C++ (ar at least in standard C++ mode?). The result is that cmake
dtects that strdup() is available but the C++ compiler fails to
compile code using it. We just use _strdup() on Windows.
/* If Model-Checking support was requested */
#cmakedefine HAVE_MC @HAVE_MC@
/* If Model-Checking support was requested */
#cmakedefine HAVE_MC @HAVE_MC@
-#cmakedefine SIMGRID_HAVE_STRDUP @SIMGRID_HAVE_STRDUP@
-#cmakedefine SIMGRID_HAVE__STRDUP @SIMGRID_HAVE__STRDUP@
-
SG_END_DECL()
#endif /* SIMGRID_PUBLIC_CONFIG_H */
SG_END_DECL()
#endif /* SIMGRID_PUBLIC_CONFIG_H */
{
char *res = NULL;
if (s) {
{
char *res = NULL;
if (s) {
-# if defined(SIMGRID_HAVE_STRDUP)
+# if !defined(_XBT_WIN32)
-# elif defined(SIMGRID_HAVE__STRDUP)
- res = _strdup(s);
- size_t len = strlen(s);
- res = malloc(len + 1);
- if (res)
- memcpy(res, s, len + 1);
-# endif
+ res = _strdup(s);
+# endif
if (!res)
xbt_die("memory allocation error (strdup returned NULL)");
}
if (!res)
xbt_die("memory allocation error (strdup returned NULL)");
}
return res;
}
#else /* non __GNUC__ */
return res;
}
#else /* non __GNUC__ */
-# if defined(SIMGRID_HAVE_STRDUP)
+# if !defined(_XBT_WIN32)
# define xbt_strdup(s) strdup(s)
# define xbt_strdup(s) strdup(s)
-# elif defined(SIMGRID_HAVE__STRDUP
-# define xbt_strdup(s) _strdup(s)
+# define xbt_strdup(s) _strdup(s)
# endif
# define xbt_malloc(n) malloc(n)
# define xbt_malloc0(n) calloc(n,1)
# endif
# define xbt_malloc(n) malloc(n)
# define xbt_malloc0(n) calloc(n,1)