D
dank
http://msdn2.microsoft.com/en-us/library/tcxf1dw6.aspx
describes the integer format modifiers accepted by Microsoft's printf.
http://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html
describes the integer format modifiers accepted by glibc's printf.
They differ (no big surprise), but the difference that's
bugging me today is how size_t integers are handled.
It looks like one has to do %Id (that's a capital i) in windows, and
%zd everywhere else.
This didn't use to matter much, but now that 64 bit portability is
becoming important, source code that used to happily print size_t's
with %d
is hurting. The way I've been dealing with it is to imitate
<inttypes.h>
and define a macro holding the format char for size_t, say
#ifdef MSVC
#define PRIdS "Id"
#else
#define PRIdS "zd"
#endif
....
printf("sizeof(foo_t) is %" PRIdS ".\n", sizeof(foo_t));
but that's awful ugly. I don't suppose we could convince Microsoft to
push out an updated msvcrt.dll that supported the 'z' format modifier
as an alternative to their 'I' modifier?
- Dan
describes the integer format modifiers accepted by Microsoft's printf.
http://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html
describes the integer format modifiers accepted by glibc's printf.
They differ (no big surprise), but the difference that's
bugging me today is how size_t integers are handled.
It looks like one has to do %Id (that's a capital i) in windows, and
%zd everywhere else.
This didn't use to matter much, but now that 64 bit portability is
becoming important, source code that used to happily print size_t's
with %d
is hurting. The way I've been dealing with it is to imitate
<inttypes.h>
and define a macro holding the format char for size_t, say
#ifdef MSVC
#define PRIdS "Id"
#else
#define PRIdS "zd"
#endif
....
printf("sizeof(foo_t) is %" PRIdS ".\n", sizeof(foo_t));
but that's awful ugly. I don't suppose we could convince Microsoft to
push out an updated msvcrt.dll that supported the 'z' format modifier
as an alternative to their 'I' modifier?
- Dan