diff options
-rw-r--r-- | upb/port_def.inc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/upb/port_def.inc b/upb/port_def.inc index 1b7c335..8362f78 100644 --- a/upb/port_def.inc +++ b/upb/port_def.inc @@ -77,13 +77,19 @@ #define UPB_NORETURN #endif -#if defined(_WIN32) || defined(WIN32) -/* Windows versions */ +#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L +/* C99/C++11 versions. */ +#include <stdio.h> +#define _upb_snprintf snprintf +#define _upb_vsnprintf vsnprintf +#define _upb_va_copy(a, b) va_copy(a, b) +#elif defined(_MSC_VER) +/* Microsoft C/C++ versions. */ #include <stdarg.h> #include <stdio.h> -#if defined(_MSC_VER) && _MSC_VER < 1900 -int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); +#if _MSC_VER < 1900 int msvc_snprintf(char* s, size_t n, const char* format, ...); +int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); #define UPB_MSVC_VSNPRINTF #define _upb_snprintf msvc_snprintf #define _upb_vsnprintf msvc_vsnprintf @@ -92,13 +98,6 @@ int msvc_snprintf(char* s, size_t n, const char* format, ...); #define _upb_vsnprintf vsnprintf #endif #define _upb_va_copy(a, b) va_copy(a, b) -#else -#if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L -/* C99/C++11 versions. */ -#include <stdio.h> -#define _upb_snprintf snprintf -#define _upb_vsnprintf vsnprintf -#define _upb_va_copy(a, b) va_copy(a, b) #elif defined __GNUC__ /* A few hacky workarounds for functions not in C89. * For internal use only! @@ -111,7 +110,6 @@ int msvc_snprintf(char* s, size_t n, const char* format, ...); #else #error Need implementations of [v]snprintf and va_copy #endif -#endif #ifdef __cplusplus #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || \ |