From 6b6ee5440e76c8d3b2af37f194974f9b946b996e Mon Sep 17 00:00:00 2001 From: Yuri Krupenin Date: Mon, 3 Jan 2011 17:00:53 +0300 Subject: [PATCH] Minimal set of fixes to build with MinGW. --- components/esm/esm_reader.hpp | 2 ++ libs/platform/string.h | 4 ++-- libs/platform/strings.h | 21 +++++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/components/esm/esm_reader.hpp b/components/esm/esm_reader.hpp index 64e0861b5..3b9f241f1 100644 --- a/components/esm/esm_reader.hpp +++ b/components/esm/esm_reader.hpp @@ -1,6 +1,8 @@ #ifndef _ESM_READER_H #define _ESM_READER_H +#include + #include #include #include diff --git a/libs/platform/string.h b/libs/platform/string.h index dc25279fe..d4302ae78 100644 --- a/libs/platform/string.h +++ b/libs/platform/string.h @@ -1,9 +1,9 @@ -// Wrapper for string.h on Mac +// Wrapper for string.h on Mac and MinGW #ifndef _STRING_WRAPPER_H #define _STRING_WRAPPER_H #include -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__MINGW32__) // need our own implementation of strnlen static size_t strnlen(const char *s, size_t n) { diff --git a/libs/platform/strings.h b/libs/platform/strings.h index 0879ed87b..fd917065d 100644 --- a/libs/platform/strings.h +++ b/libs/platform/strings.h @@ -1,13 +1,18 @@ -// Wrapper for MSVC +// Wrapper for MSVC/GCC #ifndef _STRINGS_WRAPPER_H #define _STRINGS_WRAPPER_H -#ifdef WIN32 -#pragma warning(disable: 4996) -#define strcasecmp stricmp -#define snprintf _snprintf + +// For GCC, just use strings.h (this applies to mingw too) +#if defined(__GNUC__) +# include +#elif defined(MSVC) +# pragma warning(disable: 4996) +# define strcasecmp stricmp +# define snprintf _snprintf #else -#include -#endif +# warning "Unable to determine your compiler, you should probably take a look here." +# include // Just take a guess +#endif -#endif +#endif /* _STRINGS_WRAPPER_H */