Drop C89/C90 support and MSVC prior to Visual Studio 2015. upb previously attempted to support C89 and pre-2015 versions of Visual Studio. This was to support older compilers with limited C99 support (particularly MSVC). But as of last August, even gRPC has dropped support for MSVC prior to 2015 https://github.com/grpc/grpc.io/commit/c87276d058d4a8464204bd12b7892f0f3bf0071d Therefore it seems safe for upb to no longer attempt C89 support (we were already not truly C89 compliant, with our use of "bool"). We now explicitly require C99 or greater and MSVC 2015 or greater. This cleaned up port_def.inc a fair bit. I took the chance to also remove some obsolete macros.
diff --git a/upb/json_encode.c b/upb/json_encode.c index 587772d..628d1c1 100644 --- a/upb/json_encode.c +++ b/upb/json_encode.c
@@ -4,14 +4,16 @@ #include <ctype.h> #include <float.h> #include <inttypes.h> +#include <math.h> +#include <setjmp.h> #include <stdarg.h> #include <stdio.h> #include <string.h> -#include <setjmp.h> #include "upb/decode.h" #include "upb/reflection.h" +/* Must be last. */ #include "upb/port_def.inc" typedef struct { @@ -76,7 +78,7 @@ va_list args; va_start(args, fmt); - n = _upb_vsnprintf(e->ptr, have, fmt, args); + n = vsnprintf(e->ptr, have, fmt, args); va_end(args); if (UPB_LIKELY(have > n)) { @@ -268,9 +270,9 @@ } static void jsonenc_double(jsonenc *e, const char *fmt, double val) { - if (val == UPB_INFINITY) { + if (val == INFINITY) { jsonenc_putstr(e, "\"Infinity\""); - } else if (val == -UPB_INFINITY) { + } else if (val == -INFINITY) { jsonenc_putstr(e, "\"-Infinity\""); } else if (val != val) { jsonenc_putstr(e, "\"NaN\"");