The C standard does not define 'ssize_t' - that is a POSIX invention.
However, C does require %zd to print a signed integer type corresponding
to a size_t. But looking further, I can find nothing in the POSIX
standard that requires 'ssize_t' to be the signed integer corresponding
to a size_t. In fact, it seems like a 32-bit implementation, where both
'long' and 'int' are 32 bits, would be compliant if 'size_t' is unsigned
long while 'ssize_t' is int. But doing this would cause compiler
warnings on attempts to do printf("%zd",(ssize_t)1), for compilers that
know how to warn on mismatches between specifiers and types.Should POSIX be enhanced to require that size_t and ssize_t be signed and unsigned counterparts of the same rank type, so that usage of %zd becomes portable? And if not, what is the preferred portable way for printing ssize_t values? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
