On Sun, Jan 29, 2012 at 05:57:39PM -0800, 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.
And C++ doesn't officially support C99. Prior to C++11 anyway, but I don't foresee myself doing any major projects in C++11 now that I have something better, i.e., D. I just can't see myself doing any more personal projects in C++, and at my day job we actually migrated from C++ to C a few years ago, and we're still happy we did so. (Don't ask, you don't want to know. When a single function call requires 6 layers of needless abstraction including a layer involving fwrite, fork, and exec, and when dtors do useful work other than cleanup, it's time to call it quits.) > 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 could've been worse, though. We're lucky (most) compiler vendors decided not to make int 64 bits. That alone would've broken 90% of existing C code out there, some in obvious ways and others in subtle ways that you only find out after it's deployed on your client's production system. T -- Two wrongs don't make a right; but three rights do make a left...