Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe13.iad.POSTED!00000000!not-for-mail Newsgroups: comp.std.c Subject: Re: PRI* considered harmful User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (berkeley-unix) References: <87mxgqhk3x.fsf@once.weird.com> <8762ndhnfs.fsf@once.weird.com> From: "Greg A. Woods" X-Face: .}E4CW({2'v<\JefgY&(9#RJD?~_7.KTC$+RklqwlB/<)^)~X0i*J?m)SXpHA8'9FHn5Fz*eVTH5=_C>]XK#"dLOyD`#tbEh1_8v-hwwR{.X)+b-!\4mM] 1HqG#"@VSI$1MNvRk\4>qsCclW|Ns4V/2poz=gS-+~m8\%5eVq]a\3.>T>U/f8A Message-ID: <87oc15g10i.fsf@once.weird.com> Cancel-Lock: sha1:P666zSo/s7y99fr6pgZ3tzvgzns= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 41 NNTP-Posting-Host: 24.67.98.78 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: newsfe13.iad 1310078942 24.67.98.78 (Thu, 07 Jul 2011 22:49:02 UTC) NNTP-Posting-Date: Thu, 07 Jul 2011 22:49:02 UTC Date: Thu, 07 Jul 2011 15:49:01 -0700 Xref: x330-a1.tempe.blueboxinc.net comp.std.c:629 Keith Thompson writes: > > (I suppose PRI32d could be defined as "ld" even if int32_t is a typedef > for int, but only if "%ld" actually works with an int32_t or int > argument.) Exactly, and thus a compiler that cares about portability must then complain that format of "%ld" does not match type of "int", and rightfully so. You can't escape the casts with the PRI* macros even if you're just trying to play with ints and longs. (Maybe the standard should be fixed in this respect, but it wouldn't really solve enough of the problems with the PRI* debacle.) > The language and library don't make it *easy* to print raw time_t > values because there's rarely a good reason to do so. That's what > strftime() is for. It might be rare in your world, but it's far from rare in my world. Also, I repeat, C99 strftime() is unable to print the value of a time_t as an integer representation of seconds since the epoch of time_t. (C99 does not have the '%s' specifier that many implementations do have.) > The only library-defined *integer* type that isn't covered, as far > as I can tell, is wchar_t. You wouldn't normally want to print that > as integer value anyway. It's not the only one (not even close). Never assume what's "normal", especially not when designing a standard. -- Greg A. Woods RoboHack living on the edge http://www.robohack.ca/