From 663ff552710e460946ba6aed6b431602a8019a08 Mon Sep 17 00:00:00 2001 From: Kemmler Date: Sat, 18 Jul 2015 16:56:41 -0400 Subject: [PATCH] Very preliminary work with Visual Studio 2015 Community RC/RTM, resolve some version-specific build errors: 1. Standard library functions snprintf & vsnprintf are available thusly named (without the prepended underscores). Someone may want to check my conditionals against non-MSVC compilers, though. 2. zone/bonuses.cpp throws an internal compiler error with optimize enabled; #pragma disable optimization on VS2015 only. Doing further testing as to whether we have to disable optimization for the WHOLE file ... --- common/tcp_connection.h | 4 +++- common/types.h | 4 +++- zone/beacon.cpp | 6 ++++-- zone/bonuses.cpp | 14 ++++++++++++++ zone/corpse.cpp | 6 ++++-- zone/encounter.cpp | 10 ++++++---- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/common/tcp_connection.h b/common/tcp_connection.h index ae02b9c56..c3fa5cd51 100644 --- a/common/tcp_connection.h +++ b/common/tcp_connection.h @@ -23,7 +23,9 @@ */ #ifdef _WINDOWS - #define snprintf _snprintf + #if (!defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1900)) + #define snprintf _snprintf + #endif #define strncasecmp _strnicmp #define strcasecmp _stricmp diff --git a/common/types.h b/common/types.h index 2e1b5d3f3..b3be97d32 100644 --- a/common/types.h +++ b/common/types.h @@ -43,7 +43,9 @@ typedef unsigned char uchar; typedef const char Const_char; //for perl XS #ifdef _WINDOWS - #define snprintf _snprintf + #if (!defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1900)) + #define snprintf _snprintf + #endif #define strncasecmp _strnicmp #define strcasecmp _stricmp typedef void ThreadReturnType; diff --git a/zone/beacon.cpp b/zone/beacon.cpp index 0df02b201..21943ecee 100644 --- a/zone/beacon.cpp +++ b/zone/beacon.cpp @@ -26,8 +26,10 @@ target to center around. class Zone; #ifdef _WINDOWS - #define snprintf _snprintf - #define vsnprintf _vsnprintf + #if (!defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1900)) + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #endif #define strncasecmp _strnicmp #define strcasecmp _stricmp #endif diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 155dfc4ae..ddabe89d5 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -38,6 +38,16 @@ #include "../common/unix.h" #endif +// Avoid an internal compiler error in VS 2015 +// Community RC (free) with the /O2 compiler +// option enabled on x64 build; definite fail on +// building Release-X64. Disabling optimizations +// for the entire file might be overkill and/or +// inapplicable to other builds, more testing needed. +// Bug has been reported to MS, fix ETA unknown. +#if (defined(_MSC_VER) && defined(_WIN64)&& _MSC_VER==1900) + #pragma optimize( "", off ) +#endif void Mob::CalcBonuses() { @@ -4669,3 +4679,7 @@ void Mob::NegateSpellsBonuses(uint16 spell_id) } } +// See line 41 above, more or less +#if (defined(_MSC_VER) && defined(_WIN64)&& _MSC_VER==1900) + #pragma optimize( "", on ) +#endif diff --git a/zone/corpse.cpp b/zone/corpse.cpp index af937e41b..b0e9bef0d 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -22,8 +22,10 @@ Child of the Mob class. */ #ifdef _WINDOWS - #define snprintf _snprintf - #define vsnprintf _vsnprintf + #if (!defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1900)) + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #endif #define strncasecmp _strnicmp #define strcasecmp _stricmp #endif diff --git a/zone/encounter.cpp b/zone/encounter.cpp index 1f77de43a..01d4ef670 100644 --- a/zone/encounter.cpp +++ b/zone/encounter.cpp @@ -17,10 +17,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef _WINDOWS -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#define strncasecmp _strnicmp -#define strcasecmp _stricmp + #if (!defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1900)) + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #endif + #define strncasecmp _strnicmp + #define strcasecmp _stricmp #endif #include "../common/races.h"