trink / symtseries

C Library providing means of symbolic analysis on time series data currently based on iSAX paper (http://www.cs.ucr.edu/~eamonn/iSAX/iSAX.html)
Mozilla Public License 2.0
3 stars 3 forks source link

missing %z printf specifier when compiling with mingw #49

Open torbiak opened 8 years ago

torbiak commented 8 years ago

By default mingw uses the Windows CRT's printf, which lacks %z, and using %lu would also be problematic as it isn't ISO C and causes an error when using -Werror.

trink commented 8 years ago

That is why it is compiled with -D__USE_MINGW_ANSI_STDIO. Are you having an actual problem building it with the provided cmake build scripts?

Edit: works fine on my tdm-gcc-4.7.1-2 install of mingw

torbiak commented 8 years ago

When I build heka (e99096e with tdm-gcc-4.7.1.-2) it fails on this dependency of lua_sandbox. I didn't actually try building it standalone, but assumed that cmake would be called recursively.

trink commented 8 years ago

It does, I just tried a Heka build with e99096e and that also works. If you find out what is different with your environment we can apply a fix if appropriate.

torbiak commented 8 years ago

I built Lua so I could build symtseries standalone, and it looks like snprintf is being redirected to MSVCRT's implementation, against what I'd expect from reading tdm-gcc-4.7.1's include/stdio.h, which says the uglified names need to be used to get the MS behaviour. However, printf is being linked to the mingw implementation as expected with -D__USE_MINGW_ANSI_STDIO.

If I #define snprintf __mingw_snprintf or replace the PRIuSIZE macros in the format strings being passed to mu_assert (which calls snprintf) it compiles cleanly.

C:\home\code\ext\symtseries\release>gcc -std=c99 -pedantic -Werror -Wall -Wextra -D__USE_MINGW_ANSI_STDIO=1 -DSTS_COMPILE_UNIT_TESTS -IC:/home/code/ext/symtseries/incl
ude -IC:/home/code/ext/symtseries/src/test ..\src\symtseries.c
..\src\symtseries.c: In function 'test_to_sax_stationary':
..\src\symtseries.c:690:17: error: unknown conversion type character 'z' in format [-Werror=format]
..\src\symtseries.c:690:17: error: too many arguments for format [-Werror=format-extra-args]
..\src\symtseries.c: In function 'test_sliding_word':
..\src\symtseries.c:729:13: error: unknown conversion type character 'z' in format [-Werror=format]
..\src\symtseries.c:729:13: error: too many arguments for format [-Werror=format-extra-args]
..\src\symtseries.c:736:13: error: unknown conversion type character 'z' in format [-Werror=format]
..\src\symtseries.c:736:13: error: too many arguments for format [-Werror=format-extra-args]
cc1.exe: all warnings being treated as errors

C:\home\code\ext\symtseries\release>gcc -Dsnprintf=__mingw_snprintf -std=c99 -pedantic -Werror -Wall -Wextra -D__USE_MINGW_ANSI_STDIO=1 -DSTS_COMPILE_UNIT_TESTS -IC:/h
ome/code/ext/symtseries/include -IC:/home/code/ext/symtseries/src/test ..\src\symtseries.c

C:\home\code\ext\symtseries\release>gcc --version
gcc (tdm-1) 4.7.1
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

C:\home\code\ext\symtseries\release>cmake --version
cmake version 3.0.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

I get similar errors with tdm-gcc-5.1.0, that can also be avoided with -Dsnprintf=__mingw_snprintf.