fixes for MSVC non-standard C library

strcase => _stricmp
strncase => _strnicmp
strdup => _strdup
snprintf => _snprintf

a compliant snprintf() is supposed to be available
in MS Visual Studio 2015 and later
This commit is contained in:
Thomas Bernard 2018-02-20 15:31:45 +01:00
parent 87e4cfad94
commit 60beebc9ac
11 changed files with 38 additions and 9 deletions

View File

@ -40,11 +40,8 @@
#if !defined(_MSC_VER) #if !defined(_MSC_VER)
#include <strings.h> #include <strings.h>
#else #else
#if (_MSC_VER >= 1400) #define strdup _strdup
#define strncasecmp _memicmp #define strncasecmp _strnicmp
#else
#define strncasecmp memicmp
#endif
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#if !defined(__VBCC__) && !defined(_MSC_VER) #if !defined(__VBCC__) && !defined(_MSC_VER)

View File

@ -53,6 +53,12 @@
#include <stdlib.h> #include <stdlib.h>
#if defined(_MSC_VER)
#include <stdio.h>
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#endif
#include "errors.h" #include "errors.h"
#include "global.h" #include "global.h"

View File

@ -43,7 +43,10 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <stdio.h> #include <stdio.h>
#define strdup _strdup
#if _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif
#else #else
#include <strings.h> #include <strings.h>
#include <unistd.h> #include <unistd.h>

View File

@ -27,7 +27,7 @@
#if defined(__WIN32__) || defined(WIN32) #if defined(__WIN32__) || defined(WIN32)
#include <windows.h> #include <windows.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#elif defined(__macosx__) || defined(__FreeBSD__) #elif defined(__macosx__) || defined(__FreeBSD__)

View File

@ -35,7 +35,6 @@
#endif #endif
#include <stdio.h> #include <stdio.h>
//#include <fcntl.h>
#include <string.h> #include <string.h>
#if !defined(__VBCC__) && !defined(_MSC_VER) #if !defined(__VBCC__) && !defined(_MSC_VER)
@ -58,10 +57,13 @@
#ifdef GRAFX2_CATCHES_SIGNALS #ifdef GRAFX2_CATCHES_SIGNALS
#include <signal.h> #include <signal.h>
#endif #endif
#ifdef _MSC_VER #if defined(_MSC_VER)
#include <stdio.h> #define strncasecmp _strnicmp
#define strdup _strdup
#if _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#endif
#include "buttons.h" #include "buttons.h"
#include "const.h" #include "const.h"

View File

@ -33,6 +33,12 @@
#endif #endif
#if defined(WIN32) #if defined(WIN32)
#include <windows.h> #include <windows.h>
#if defined(_MSC_VER)
#define strdup _strdup
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#endif
#endif #endif
#include <limits.h> #include <limits.h>
#include <SDL_image.h> #include <SDL_image.h>

View File

@ -29,6 +29,9 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER)
#define strdup _strdup
#endif
#include "const.h" #include "const.h"
#include "errors.h" #include "errors.h"

View File

@ -60,8 +60,11 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <stdio.h> #include <stdio.h>
#define strdup _strdup
#if _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#endif
// Virtual keyboard is ON by default on these platforms: // Virtual keyboard is ON by default on these platforms:
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(GCWZERO) #if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) || defined(GCWZERO)

View File

@ -40,8 +40,12 @@
// POSIX calls it strcasecmp, Windows uses stricmp... no ANSI standard. // POSIX calls it strcasecmp, Windows uses stricmp... no ANSI standard.
#ifdef WIN32 #ifdef WIN32
#ifdef _MSC_VER
#define strcasecmp _stricmp
#else
#define strcasecmp stricmp #define strcasecmp stricmp
#endif #endif
#endif
// Definition of the base data types // Definition of the base data types
/// 8bit unsigned integer /// 8bit unsigned integer

View File

@ -52,8 +52,11 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <stdio.h> #include <stdio.h>
#define strdup _strdup
#if _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#endif
#include <SDL_image.h> #include <SDL_image.h>
#include "SFont.h" #include "SFont.h"

View File

@ -31,8 +31,10 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <stdio.h> #include <stdio.h>
#if _MSC_VER < 1900
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#endif
#include "windows.h" #include "windows.h"