diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2019-07-30 17:49:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-30 17:49:03 -0700 |
commit | 76d75aec66e1e6f173f3b6668601108ed453f3d3 (patch) | |
tree | b4bc5af6bb92804bae676dd32c3b21cdd78972aa /upb/port_def.inc | |
parent | 423ea5ca9ce8da69611e6e95559efcb3a1ba8ad8 (diff) | |
parent | 7a1e6aa84ba857d2e3cdc6e5fd50e3bda210c164 (diff) |
Merge pull request #195 from veblush/vsnprintf
Fix compiler error on Windows
Diffstat (limited to 'upb/port_def.inc')
-rw-r--r-- | upb/port_def.inc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/upb/port_def.inc b/upb/port_def.inc index 5220c29..0650920 100644 --- a/upb/port_def.inc +++ b/upb/port_def.inc @@ -75,8 +75,16 @@ /* Windows versions */ #include <stdarg.h> #include <stdio.h> -#define _upb_snprintf _snprintf_s -#define _upb_vsnprintf _vsnprintf_s +#if defined(_MSC_VER) && _MSC_VER < 1900 +int msvc_vsnprintf(char* s, size_t n, const char* format, va_list arg); +int msvc_snprintf(char* s, size_t n, const char* format, ...); +#define UPB_MSVC_VSNPRINTF +#define _upb_snprintf msvc_snprintf +#define _upb_vsnprintf msvc_vsnprintf +#else +#define _upb_snprintf snprintf +#define _upb_vsnprintf vsnprintf +#endif #define _upb_va_copy(a, b) va_copy(a, b) #else #if __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L @@ -130,3 +138,11 @@ #else #define UPB_UNREACHABLE() do { assert(0); } while(0) #endif + +/* UPB_INFINITY representing floating-point positive infinity. */ +#include <math.h> +#ifdef INFINITY +#define UPB_INFINITY INFINITY +#else +#define UPB_INFINITY (1.0 / 0.0) +#endif |