win32: don't assume the format specifier for the stdlib printf/scanf like functions

When using the mingw printf shims for C99 compat the msvc format specifiers don't work
and the build fails.

Ideally we would use glib functions which abstract this away, but in the error handler context
we shouldn't call back into glib. And for scanf we don't have a glib wrapper.

Instead call the "secure" versions provided by the win32 API (_snprintf_s/fprintf_s/sscanf_s)
which mingw doesn't replace.
This commit is contained in:
Christoph Reiter
2019-08-10 19:55:53 +02:00
parent 179fdc5239
commit 6095b9bd3c
3 changed files with 27 additions and 24 deletions

View File

@@ -123,6 +123,7 @@ main (int argc,
#ifndef G_OS_WIN32
# define SCAN_FORMAT64 FORMAT64
#else
# define sscanf sscanf_s
# define SCAN_FORMAT64 "%I64d %I64u\n"
#endif
string = g_strdup_printf (FORMAT64, gi64t1, gu64t1);
@@ -138,6 +139,7 @@ main (int argc,
#ifndef G_OS_WIN32
# define SCAN_FORMATSIZE FORMATSIZE
#else
# define sscanf sscanf_s
# define SCAN_FORMATSIZE "%Id %Iu\n"
#endif
string = g_strdup_printf (FORMATSIZE, gsst1, gst1);