summaryrefslogtreecommitdiff
path: root/upb
diff options
context:
space:
mode:
authorEsun Kim <veblush@google.com>2019-08-09 08:43:35 -0700
committerEsun Kim <veblush@google.com>2019-08-09 08:43:35 -0700
commitce4c4fd76b95519f255486f1111721efb5c79c4f (patch)
tree422a6e9ddc6727e2ddf47cf0f31e4a7865bb114c /upb
parentb70f68269a7d51c5ce372a93742bf6960215ffef (diff)
Clean up MSVC port for vsnprintf
Diffstat (limited to 'upb')
-rw-r--r--upb/port_def.inc22
1 files changed, 10 insertions, 12 deletions
diff --git a/upb/port_def.inc b/upb/port_def.inc
index 3e0a7f4..6779363 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__) || \
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback