On Sunday, January 29, 2012 17:57:39 Walter Bright wrote: > On 1/29/2012 3:31 PM, H. S. Teoh wrote: > > Yeah, size_t especially drives me up the wall. Is it %u, %lu, or %llu? > > I think either gcc or C99 actually has a dedicated printf format for > > size_t, except that C++ doesn't include parts of C99, so you end up with > > format string #ifdef nightmare no matter what you do. I'm so glad that > > %s takes care of it all in D. Yet another thing D has done right. > > size_t does have a C99 Standard official format %z. The trouble is, > > 1. many compilers *still* don't implement it. > > 2. that doesn't do you any good for any other typedef's that change size. > > printf is the single biggest nuisance in porting code between 32 and 64 > bits.
It's even worse with code which you're trying to have be cross-platform between 32-bit and 64-bit. Microsoft added I32 and I64. which helps, but then you still need to add a wrapper to printf for Posix to handle them unless you want to ifdef all of your printf calls. About the only positive thing that I can say about that whole mess is that it's because of that that I learned that string literals are unaffected by macros in C/C++. The fact that I can just do %s with writefln in D and not worry about it is so fantastic it's not even funny. - Jonathan M Davis