From: Antonio Ospite Date: Tue, 27 Feb 2018 16:03:36 +0000 (+0100) Subject: am7xxx: fix C99 conformance for printf & co. when compiling with MinGW X-Git-Tag: v0.1.7~17 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/bbebd199987581ee6f344c89bfb02237dc0ab0bd?hp=bbebd199987581ee6f344c89bfb02237dc0ab0bd am7xxx: fix C99 conformance for printf & co. when compiling with MinGW C99 format specifiers like "%hhd" are used with log_message() but MinGW (and Windows) does not really supports them, so the compiler suggests to use the "gnu_printf" attribute for the function. However "gnu_printf"is not available on clang so it's not an option, a better alternative is the solution suggested by MinGW at https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ The change fixes the following warnings when compiling with MinGW: .../libam7xxx/src/am7xxx.c: In function ‘log_message’: .../libam7xxx/src/am7xxx.c:647:3: warning: function ‘log_message’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] vfprintf(stderr, fmt, ap); ^~~~~~~~ .../libam7xxx/src/am7xxx.c: In function ‘open_device’: .../libam7xxx/src/am7xxx.c:772:15: warning: unknown conversion type character ‘h’ in format [-Wformat=] debug(ctx, "Cannot set configuration %hhu\n", ^ .../libam7xxx/src/am7xxx.c:65:85: note: in definition of macro ‘debug’ #define debug(ctx, ...) log_message(ctx, AM7XXX_LOG_DEBUG, __func__, 0, __VA_ARGS__) ^~~~~~~~~~~ .../libam7xxx/src/am7xxx.c:772:15: warning: too many arguments for format [-Wformat-extra-args] debug(ctx, "Cannot set configuration %hhu\n", ^ .../libam7xxx/src/am7xxx.c:65:85: note: in definition of macro ‘debug’ #define debug(ctx, ...) log_message(ctx, AM7XXX_LOG_DEBUG, __func__, 0, __VA_ARGS__) ^~~~~~~~~~~ .../libam7xxx/src/am7xxx.c:785:14: warning: unknown conversion type character ‘h’ in format [-Wformat=] debug(ctx, "Cannot claim interface %hhu\n", ^ .../libam7xxx/src/am7xxx.c:65:85: note: in definition of macro ‘debug’ #define debug(ctx, ...) log_message(ctx, AM7XXX_LOG_DEBUG, __func__, 0, __VA_ARGS__) ^~~~~~~~~~~ .../libam7xxx/src/am7xxx.c:785:14: warning: too many arguments for format [-Wformat-extra-args] debug(ctx, "Cannot claim interface %hhu\n", ^ .../libam7xxx/src/am7xxx.c:65:85: note: in definition of macro ‘debug’ #define debug(ctx, ...) log_message(ctx, AM7XXX_LOG_DEBUG, __func__, 0, __VA_ARGS__) ^~~~~~~~~~~ .../libam7xxx/src/am7xxx.c:803:14: warning: unknown conversion type character ‘h’ in format [-Wformat=] debug(ctx, "libusb configuration changed (expected: %hhu, current: %d)\n", ^ .../libam7xxx/src/am7xxx.c:65:85: note: in definition of macro ‘debug’ #define debug(ctx, ...) log_message(ctx, AM7XXX_LOG_DEBUG, __func__, 0, __VA_ARGS__) ^~~~~~~~~~~ .../libam7xxx/src/am7xxx.c:803:14: warning: too many arguments for format [-Wformat-extra-args] debug(ctx, "libusb configuration changed (expected: %hhu, current: %d)\n", ^ .../libam7xxx/src/am7xxx.c:65:85: note: in definition of macro ‘debug’ #define debug(ctx, ...) log_message(ctx, AM7XXX_LOG_DEBUG, __func__, 0, __VA_ARGS__) ^~~~~~~~~~~ ---