trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Plevyak <jplev...@acm.org>
Subject Re: stdint.h
Date Wed, 19 May 2010 05:02:49 GMT

All compilers that are C99 compliant must accept
%lld as long long int where sizeof(long long int) == 8.

Sun 64 and linux 64 both have sizeof(long) == 8, but
because of C99 they also have sizeof(long long int) == 8
and %ld and %lld will both work with 64-bit arguments,
however gcc/g++ will complain if you pass a long to something
expecting %lld even if the are the same size because it is
pedantic.  This is the problem with uint64_t, because they
choose to use "long" instead of "long long int" despite
the fact that they are both the same size.

Windows Studio 2003 did not support %lld, but as of
Studio 2005 it now does.  The %I64d, like %q on FreeBSD,
is a holdover from when there was not standard solution.

I would say that if we can't find a system which doesn't
support the standard %lld for 64-bit numbers then we should
just go with the standard. It is simpler and it will only
be more right as time passes because it is the standard.

john


On 5/18/2010 9:50 PM, Mladen Turk wrote:
> On 05/19/2010 06:35 AM, John Plevyak wrote:
>>
>>
>> However, since the C99 and new C++ standard declares that long long int
>> is 64-bit and since just about everyone already has that:
>> linux, solaris, freebsd, mac, and since I have been able to use it
>> portably for several years now I would rather go that route.
>>
> 
> If we ever plan to port TS to windows (or at least some parts
> of it, then there's %I64d format, next if sizeof(long) == 8, then
> the correct format is %ld not %lld, etc.
> Think that some compiles complain if you try to use %lld instead
> %ld in such situations.
> 
> 
> 
> Regards


Mime
View raw message