Always assume that we use a gnu/c99 printf implementation

On Windows we use gnulib and elsewhere we use glibc or similar.

Also change G_GNUC_PRINTF to use gnu_printf instead of __format__ if
possible because __format__ evaluates to ms_printf under MinGW,
but we use gnulib there and not the system printf.
gnu_printf is only available with GCC>=4.4 and not with clang.

https://bugzilla.gnome.org/show_bug.cgi?id=795569
This commit is contained in:
Christoph Reiter 2018-05-05 18:33:47 +02:00 committed by Christoph Reiter
parent b437a13a70
commit 98a0ab929d
2 changed files with 9 additions and 9 deletions

View File

@ -146,10 +146,17 @@
#endif
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#if !defined (__clang__) && G_GNUC_CHECK_VERSION (4, 4)
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (gnu_printf, format_idx, arg_idx)))
#define G_GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((__format__ (gnu_scanf, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#define G_GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((__format__ (__scanf__, format_idx, arg_idx)))
#endif
#define G_GNUC_FORMAT( arg_idx ) \
__attribute__((__format_arg__ (arg_idx)))
#define G_GNUC_NORETURN \

View File

@ -1043,14 +1043,7 @@ else
ssizet_size = cc.sizeof('ssize_t')
endif
# On Windows, MSVC supports both ll and I64 as format specifiers for 64-bit
# integers, but some versions (at least 4.7.x) of MinGW only support I64.
if host_system == 'windows'
int64_m = 'I64'
else
int64_m = 'll'
endif
int64_m = 'll'
char_align = cc.alignment('char')
short_align = cc.alignment('short')
int_align = cc.alignment('int')
@ -1160,7 +1153,7 @@ if host_system == 'windows'
glibconfig_conf.set('g_pid_type', 'void*')
glibconfig_conf.set_quoted('g_pid_format', 'p')
if host_machine.cpu_family() == 'x86_64'
glibconfig_conf.set_quoted('g_pollfd_format', '%#I64x')
glibconfig_conf.set_quoted('g_pollfd_format', '%#' + int64_m + 'x')
else
glibconfig_conf.set_quoted('g_pollfd_format', '%#x')
endif