On Thu, Feb 01, 2024 at 02:01:17PM +0100, Jakub Jelinek wrote: > On Thu, Feb 01, 2024 at 12:45:31PM +0000, Jonathan Yong wrote: > > Attached patch OK? Copied inline for review convenience. > > No, I think e.g. AIX doesn't support the z modifier. > I don't see %zd or %zu used anywhere except in gcc/jit/ which presumably > doesn't work on AIX.
Or hwint.h could define PRIusize_t etc. macros and some corresponding type to be used in casts, something like #if SIZE_MAX == LONG_LONG_MAX #define PRIusize_t HOST_LONG_LONG_FORMAT "u" #define fmt_size_t unsigned long long #elif SIZE_MAX == LONG_MAX #define PRIusize_t HOST_LONG_FORMAT "u" #define fmt_size_t unsigned long #elif SIZE_MAX == INT_MAX #define PRIusize_t "u" #define fmt_size_t unsigned int #else #error "Unsupported size_t" #endif and then use "... %" PRIusize_t " ... ", ... (fmt_size_t) (some_size_t_expr), ... Or at configure time figure out which exact type size_t is say (unsigned long long vs. unsigned long vs. unsigned int) using templates and use that info to pick the right format modifier depending on that, then the casts aren't needed. Jakub