From 004c8627c1e732d75f8760964fb1dc5111838ece Mon Sep 17 00:00:00 2001 From: nnposter Date: Fri, 16 Apr 2021 02:33:39 +0000 Subject: [PATCH] Do not override snprintf in VS 2015 and newer MSVC preprocessor triggers #error in if redefined From MS doc: Beginning with the UCRT in Visual Studio 2015 and Windows 10, snprintf is no longer identical to _snprintf. The snprintf function behavior is now C99 standard compliant. Closes #2255 --- libdnet-stripped/include/dnet_winconfig.h | 6 ++++-- nbase/nbase.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libdnet-stripped/include/dnet_winconfig.h b/libdnet-stripped/include/dnet_winconfig.h index f0b2310e3..dff336dcc 100644 --- a/libdnet-stripped/include/dnet_winconfig.h +++ b/libdnet-stripped/include/dnet_winconfig.h @@ -269,8 +269,10 @@ int strlcpy(char *, const char *, int); #ifndef HAVE_STRSEP char *strsep(char **, const char *); #endif - -#define snprintf _snprintf + +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#endif /* Without this, Windows will give us all sorts of crap about using functions like strcpy() even if they are done safely */ diff --git a/nbase/nbase.h b/nbase/nbase.h index 41090f2f0..2c80d740b 100644 --- a/nbase/nbase.h +++ b/nbase/nbase.h @@ -292,7 +292,7 @@ extern "C" int vsnprintf (char *, size_t, const char *, va_list); #define putenv _putenv #define tzset _tzset -#if !defined(__GNUC__) +#if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf #endif