Since we have added format string attributes in the tap.h file, we get
these diagnostics on Windows:
CC test_bitfield.o
test_bitfield.c: In function 'run_test_unsigned_write':
test_bitfield.c:51:36: error: unknown conversion type character 'l' in format [-Werror=format=]
51 | #define DIAG_FMT_STR(val_type_fmt) "Failed reading value written \"%s\"-wise, with start=%i" \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_bitfield.c:51:36: note: in definition of macro 'DIAG_FMT_STR'
51 | #define DIAG_FMT_STR(val_type_fmt) "Failed reading value written \"%s\"-wise, with start=%i" \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_bitfield.c:173:8: note: in expansion of macro 'check_result'
173 | if (check_result(src_ui, readval, target.c, unsigned char,
| ^~~~~~~~~~~~
test_bitfield.c:175:9: note: format string is defined here
175 | "%llX")) {
| ^
By default, printf on Windows doesn't know about the `ll` format string
length modifier (as in %llx). However, we build Babeltrace with the
__USE_MINGW_ANSI_STDIO macro defined, which makes mingw use a
replacement printf implementation that knows about `ll`.
When we define our own functions with a format attribute, we must then
use __MINGW_PRINTF_FORMAT instead of `printf`. __MINGW_PRINTF_FORMAT
will take the right value, depending on __USE_MINGW_ANSI_STDIO, so it
will validate the format string according to the selected printf
implementation.
Change-Id: I89b194e915250a0e0a617817a1cd10fedb156639 Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2161 Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com> Tested-by: jenkins <jenkins@lttng.org>