Bruno Haible <[EMAIL PROTECTED]> writes: > Simon Josefsson wrote: >> (I wish there was a PRI macro for size_t types...) > > According to ISO C 99, you can use "%zu" to print a size_t value. But it's > not portable enough, and it'd be overkill to activate the printf replacement > just for the tests.
$.2 idea: Add two macros that allows you to write: size_t len; printf ("len: %" PRIz "\n", PRIzCAST(len)); If the system printf supports %zu, or if the gnulib printf module that supports %zu is enabled, the macros would be defined as: #define PRIz "zu" #define PRIzCAST(x) (x) Otherwise, the macros would be defined as: #define PRIz "lu" #define PRIzCAST(x) ((unsigned long)x) Thoughts? I'm not sure this is a good idea, the code is slightly unreadable. On the other hand, the current code is slightly unreadable already: printf ("len: %lu\n", (unsigned long) len); /Simon