summaryrefslogtreecommitdiff
path: root/upb
diff options
context:
space:
mode:
authorEsun Kim <veblush@google.com>2019-08-09 08:53:06 -0700
committerGitHub <noreply@github.com>2019-08-09 08:53:06 -0700
commit59f43cd6e3d45b28e5226ee537f3f173c1410e61 (patch)
treead20c6d08b6ccca36dd611fe087c26ff06fda5a2 /upb
parent311049a67ec6642287a0ca6783e8a9a1d313b809 (diff)
parentce4c4fd76b95519f255486f1111721efb5c79c4f (diff)
Merge pull request #204 from veblush/msvc-port
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 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__) || \
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback