From 366e9d335c4b5b12135e73808d6b47ab19dd7379 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 31 Dec 2015 17:16:26 +0500 Subject: [PATCH] Fix some compilation warnings with MSVC 2015 MSVC 2015 already defines vsnprintf() and va_copy(). --- src/windows_port.cc | 6 ++---- src/windows_port.h | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/windows_port.cc b/src/windows_port.cc index 9ccb630..b5b7194 100644 --- a/src/windows_port.cc +++ b/src/windows_port.cc @@ -44,6 +44,7 @@ // These call the windows _vsnprintf, but always NUL-terminate. #if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */ +#if !(defined(_MSC_VER) && _MSC_VER >= 1900) /* msvc 2015 already defines */ #ifdef _MSC_VER # pragma warning(push) @@ -59,8 +60,6 @@ int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) { # pragma warning(pop) #endif -#if _MSC_VER < 1900 // msvs 2015 finally includes snprintf - int snprintf(char *str, size_t size, const char *format, ...) { int r; va_list ap; @@ -70,6 +69,5 @@ int snprintf(char *str, size_t size, const char *format, ...) { return r; } -#endif - +#endif /* if !(defined(_MSC_VER) && _MSC_VER >= 1900) */ #endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */ diff --git a/src/windows_port.h b/src/windows_port.h index c8ff24f..554b9c9 100644 --- a/src/windows_port.h +++ b/src/windows_port.h @@ -63,12 +63,14 @@ * name vsnprintf, since windows defines that (but not snprintf (!)). */ #if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */ +#if !(defined(_MSC_VER) && _MSC_VER >= 1900) /* msvc 2015 already defines */ extern GFLAGS_DLL_DECL int snprintf(char *str, size_t size, const char *format, ...); extern int GFLAGS_DLL_DECL safe_vsnprintf(char *str, size_t size, const char *format, va_list ap); #define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap) #define va_copy(dst, src) (dst) = (src) +#endif #endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */ #ifdef _MSC_VER -- 2.7.4