On Fri, Jun 25, 2010 at 11:54:32PM +0200, Alistair Crooks wrote: > Even in C99, the "%lu" method will work unless size_t is bigger than > unsigned long *and* the value being printed exceeds ULONG_MAX, which > is unlikely to happen in practice.
Actually, it doesn't. This method breaks as soon as size_t != u_long and might only work in a few edge cases like the size_t being the last argument and the byte order is Little Endian. This is worse because IIRC Microsoft decided to use IL32LLP64 or something similarly fancy. A more portable approach with autoconf can be found in pkg_install, look for MISSING_SIZE_T_SUPPORT and the corresponding AC_CHECK_SIZEOF calls in configure.ac. Joerg