🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3859

Re: Why "long long" doesn't work.

#3859
From: Alan Stokes
Date: Fri, 25 Aug 1995 12:15
41 lines
2052 bytes
In <41hubq$fu3@newsbf02.news.aol.com> ffarance@aol.com (FFarance) writes:
>> From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)

>> Simpler and better would be to change the rules for varargs functions so
>> that instead of the current inegral promotions the promotion is always
>to
>> the largest integer type. Then one does not even need any modifer. Also
>> varargs functions become a lot easier to write as you no longer have to
>> worry if the argument is smaller or larger than int.

>But what about implementations that have no largest type, i.e., where the
>type is arbitrarily long.  This scheme would be impractical.  

Implementations with no largest type already cause problems with printf.
At present long is known to be the largest signed type, so I can
safely do the following:

ptrdiff_t x = 0;
printf("%ld", (long) x);

(where ptrdiff_t can be replaced by any typedef which I know to be signed & 
integral but don't know the exact type of). This is a very useful idiom,
and this cannot be done at all if there is no largest type.

Such an implementation is non-conforming in current standard C and is not a
good idea for future standards because it breaks existing code. I therefore
think it's your implementation that is impractical rather than the suggested 
scheme.

>Also, this
>change would be a major change for vendors: code would become binary
>incompatible because the stack alignment changed.  

True, although only for implementations where the stack alignment of
int is different from that of long (which probably excludes all those
where sizeof int == sizeof long).

-- 
Alan Stokes (alan@rcp.co.uk)
RCP Consultants Ltd
Didcot, UK
Technical Details
Message-ID: <ncfPwAmIBh107h@rcp.co.uk>
Path: arc1-ca.pugleaf.net!kate.ibmpcug.co.uk!rcp!alan
References: <DDt1GF.Ls0@ukpsshp1.serigate.philips.nl> <41hubq$fu3@newsbf02.news.aol.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!kate.ibmpcug.co.uk!rcp!alan
From: alan@rcp.co.uk (Alan Stokes)
Newsgroups: comp.std.c
Subject: Re: Why "long long" doesn't work.
Message-ID: <ncfPwAmIBh107h@rcp.co.uk>
Date: Fri, 25 Aug 95 12:15:35 GMT
References: <DDt1GF.Ls0@ukpsshp1.serigate.philips.nl> <41hubq$fu3@newsbf02.news.aol.com>
Organization: RCP Consultants Ltd.