fix strdup compilications when compiling with gcc and autoconf.

This commit is contained in:
Enno Rehling 2016-11-26 16:21:41 +01:00
parent 68ce6907f3
commit 43b8ff1ea8
5 changed files with 43 additions and 41 deletions

View File

@ -60,7 +60,9 @@ CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in ${CMAKE_CURRENT_SOURCE_DIR}/autoconf.h.in
${CMAKE_BINARY_DIR}/include/autoconf.h) ${CMAKE_BINARY_DIR}/include/autoconf.h)
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include)
add_definitions(-DUSE_AUTOCONF)
## skip compiler/libc detection and force cmake autoconf:
#add_definitions(-DUSE_AUTOCONF)
add_subdirectory (cutest) add_subdirectory (cutest)
add_subdirectory (cJSON) add_subdirectory (cJSON)

View File

@ -84,6 +84,7 @@ TOLUA_BINDING(settings.pkg kenel/config.h)
ENDIF() ENDIF()
set (ERESSEA_SRC set (ERESSEA_SRC
vortex.c
calendar.c calendar.c
move.c move.c
piracy.c piracy.c
@ -92,7 +93,6 @@ set (ERESSEA_SRC
alchemy.c alchemy.c
academy.c academy.c
upkeep.c upkeep.c
vortex.c
names.c names.c
lighthouse.c lighthouse.c
reports.c reports.c

View File

@ -16,20 +16,37 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/ **/
#ifndef CONFIG_H #ifndef PLATFORM_H
#define CONFIG_H #define PLATFORM_H
#ifdef NDEBUG #ifdef NDEBUG
#define LOMEM #define LOMEM
#endif #endif
#undef USE_AUTOCONF // enable X/Open 7 extensions (like strdup):
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#endif
// enable bsd string extensions, prior to glibc 2.12:
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
// enable bsd string extensions, since glibc 2.12:
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#ifndef USE_AUTOCONF
#define USE_AUTOCONF #define USE_AUTOCONF
#ifdef _MSC_VER #ifdef _MSC_VER
#undef USE_AUTOCONF
#define HAVE_STDBOOL_H #define HAVE_STDBOOL_H
#define HAVE_DIRECT__MKDIR #define HAVE_DIRECT__MKDIR
#define HAVE__ACCESS #define HAVE__ACCESS
#define VC_EXTRALEAN #define VC_EXTRALEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#pragma warning(push) #pragma warning(push)
@ -78,36 +95,22 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define _CRT_DISABLE_PERFCRIT_LOCKS #define _CRT_DISABLE_PERFCRIT_LOCKS
#endif #endif
/* define CRTDBG to enable MSVC CRT Debug library functions */
#if defined(_DEBUG) && defined(CRTDBG)
# include <crtdbg.h>
# define _CRTDBG_MAP_ALLOC
#endif
#undef USE_AUTOCONF
#elif __GNUC__ #elif __GNUC__
# define _POSIX_C_SOURCE 200809L #undef USE_AUTOCONF
# undef _DEFAULT_SOURCE
# define _DEFAULT_SOURCE
# undef __USE_BSD
# define __USE_BSD
#define HAVE_SNPRINTF #define HAVE_SNPRINTF
#define HAVE_SYS_STAT_MKDIR #define HAVE_SYS_STAT_MKDIR
#define HAVE_STRDUP #define HAVE_STRDUP
#define HAVE_UNISTD_H #define HAVE_UNISTD_H
# undef USE_AUTOCONF #endif
#endif #endif
#ifdef USE_AUTOCONF #ifdef USE_AUTOCONF
// unknown toolchain, using autoconf
#include <autoconf.h> #include <autoconf.h>
#endif #endif
#define unused_arg (void) #define unused_arg (void)
#ifndef INLINE_FUNCTION
# define INLINE_FUNCTION
#endif
#define iswxspace(c) (c==160 || iswspace(c)) #define iswxspace(c) (c==160 || iswspace(c))
#define isxspace(c) (c==160 || isspace(c)) #define isxspace(c) (c==160 || isspace(c))
@ -125,10 +128,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#if defined(HAVE_STDBOOL_H) #if defined(HAVE_STDBOOL_H)
# include <stdbool.h> # include <stdbool.h>
#else #else
@ -171,7 +170,7 @@ typedef unsigned char _Bool;
#if !defined(HAVE__STRDUP) #if !defined(HAVE__STRDUP)
#if defined(HAVE_STRDUP) #if defined(HAVE_STRDUP)
#undef _strdup #undef _strdup
#define _strdup(a) strdup(a) #define _strdup strdup
#endif #endif
#endif #endif

View File

@ -18,7 +18,7 @@ static void unicode_warning(const char *bp)
log_warning("invalid sequence in UTF-8 string: %s\n", bp); log_warning("invalid sequence in UTF-8 string: %s\n", bp);
} }
INLINE_FUNCTION int eatwhite(const char *ptr, size_t * total_size) static int eatwhite(const char *ptr, size_t * total_size)
{ {
int ret = 0; int ret = 0;

View File

@ -14,8 +14,9 @@
#include <storage.h> #include <storage.h>
#include <assert.h> #include <assert.h>
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
typedef struct dir_lookup { typedef struct dir_lookup {
char *name; char *name;
@ -32,7 +33,7 @@ void register_special_direction(struct locale *lang, const char *name)
if (token) { if (token) {
void **tokens = get_translations(lang, UT_SPECDIR); void **tokens = get_translations(lang, UT_SPECDIR);
variant var; variant var;
char *str = _strdup(name); char *str = strdup(name);
var.v = str; var.v = str;
addtoken((struct tnode **)tokens, token, var); addtoken((struct tnode **)tokens, token, var);