Le 07/07/2011 08:08, Bron Gondwana a écrit :
I've also seen it suggested that _every_ non-base-integer type _always_
be cast to [u]intmax_t and printed using PRI[ud]MAX:
printf("%" PRIuMAX, (uintmax_t) ival);
printf("%" PRIdMAX, (intmax_t) ival); /* for signed values */
The extra heavy lifting by printf() is trivial compared to the
programmer overhead of trying to define and use the right PRI* macros.
Makes sense.
Seems like a good compromise. It's also future-proof if the variable to
print changes from 32-bits to 64-bits etc.
For the time being I used that approach on the few concerned lines in
the feature I worked on. Should not be hard to change later if a better
solution is found.