Topic: printing size_t etc.


Author: thads@csn.net (Thad Smith)
Date: 1997/01/13
Raw View
In article <5bauu7$b55@mulga.cs.mu.OZ.AU>,
fjh@mundook.cs.mu.OZ.AU (Fergus Henderson) wrote:
>"David R. Tribble" <david.tribble@central.beasys.com> writes:
>
>>(BTW, this brings up a few questions about POSIX data types.
>>Specifically, how big are uid_t, gid_t, pid_t, off_t, et al?  If I have
>>to print them, do I use "%d" or "%ld"?  This is not a problem on 32-bit
>>systems, but it can be on 64-bit CPUs.  Personally, I always cast them to
>>long and use "%ld".)
>
>That used to be the correct way to do it in C -- but changes to the C
>standard, specifically the introduction of a "long long" data type --
>mean that this long-standing idiom may break.

Standard C does not have a long long data type.  There is apparently
a proposal to add this to the next version, though.  I expect that it
will be one to four years before such changes are officially adopted.

>Instead, the best way to
>do it in C is probably to cast to cast to type `longest', defined by
>
> #ifdef HAVE_LONG_LONG
> typedef long long longest;
> #else
> typedef long longest;
> #endif
>
>where HAVE_LONG_LONG must be determined using autoconf or similar
>techniques.

When there is a new version I expect that there will be a means of
using the predefined preprocessor symbols to determine that the
language conforms to the new standard in a way similar to __STDC__
now.

Thad


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]