lloyd / yajl

A fast streaming JSON parsing library in C.
http://lloyd.github.com/yajl
ISC License
2.15k stars 436 forks source link

Compiler warning: too many arguments for format #143

Open jeroen opened 9 years ago

jeroen commented 9 years ago

Compiling yajl on a recent version of mingw32 gives the following warnings:

yajl/yajl_gen.c -o yajl/yajl_gen.o
yajl/yajl_gen.c: In function 'yajl_gen_integer':
yajl/yajl_gen.c:213:5: warning: unknown conversion type character 'l' in format [-Wformat]
yajl/yajl_gen.c:213:5: warning: too many arguments for format [-Wformat-extra-args]
yajl/yajl_gen.c: At top level:
yajl/yajl_gen.c:222:0: warning: "isnan" redefined [enabled by default]
d:\compiler\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/math.h:369:0: note: this is the location of the previous definition
yajl/yajl_gen.c:223:0: warning: "isinf" redefined [enabled by default]
d:\compiler\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/math.h:330:0: note: this is the location of the previous definition

Especially the "too many arguments" one seems significant.

cjgdev commented 9 years ago

It appears that because mingw uses the msvcrt this requires a patch. I suggest something along these lines:

ifdef _WIN32

sprintf(i, "%I64d", number);

else

sprintf(i, "%lld", number);

endif

Also, yajl_test.c ln. 82 will require the same patch.

jeroen commented 9 years ago

Thanks! So does "%I64d" generate the same output in windows as "%lld" in unix? Do you maybe have a reference on msvcrt sprintf parameters?