]> sigrok.org Git - libsigrok.git/commit - src/libsigrok-internal.h
Build: Force ISO-conforming format syntax on MinGW
authorDaniel Elstner <redacted>
Sun, 13 Sep 2015 13:07:54 +0000 (15:07 +0200)
committerDaniel Elstner <redacted>
Sun, 13 Sep 2015 13:11:27 +0000 (15:11 +0200)
commit7419638d4c5d21dadccfd8f234c5671c5330dc33
tree5e796ff76dc0bb7d44cf11a74c698544a0b5b759
parent22c50ed973443db12a5569dbc3d698bf98167833
Build: Force ISO-conforming format syntax on MinGW

On MinGW, two implementations of printf() are available: either
the Microsoft native one or a standard-conforming replacement from
gnulib. Since we build in C99 mode, headers such as <inttypes.h>
already select the standard-conforming variant. However, MinGW's
GCC does not seem to know about this and assumes MS-style format
syntax by default, which triggers a lot of wrong warnings.

Thus, on MinGW, explicitly decorate sr_log() with the gnu_printf
format flavor attribute. Also use GLib's printf replacements in
the logging implementation to make sure we link to a conforming
printf on any platform, independently of the compiler flags.

This gets rid of the mistaken -Wformat warnings for sr_log(), but
does not cover functions such as g_strdup_printf() which do not
explicitly specify the gnu_printf flavor in the format attribute.
This can be overcome by adding "-D__printf__=__gnu_printf__" to
CPPFLAGS, but it would be inappropriate for libsigrok to define
this on its own.
src/libsigrok-internal.h
src/log.c