sizeof(long long)
Erik Trulsson
ertr1013@student.uu.se
Tue Nov 19 09:33:00 GMT 2002
On Tue, Nov 19, 2002 at 03:28:28PM +0100, Svein E. Seldal wrote:
> Hi,
>
> Is it a strict requirement of C that "long long" is 64-bits? Or is it
> simply that sizeof(long long)>sizeof(long) (or maybe >=)?
"long long" must be *at least* 64 bits. (And should be at least as wide as
long.)
>
> In the AVR target, this the sizeof's are distributed as such:
> sizeof(char)=1, sizeof(short)=sizeof(int)=2, sizeof(long)=4, sizeof(long
> long)=8.
That is fine. (Assuming 8-bit bytes.)
>
> Since this is a small microcontroller, it has the -mint8 option, which
> does the following: sizeof(char)=sizeof(short)=sizeof(int)=1,
> sizeof(long)=2 and sizeof(long long)=8.
This is not acceptable to the C standard, which requires that
short and int must be at least 16 bits each and that long must have at
least 32 bits.
(Actually the C standard talks about what values must be representable by
the various types, but it translates to the above bitsizes.)
>
> Note that there is a gap between long and long long. No 32-bits types
> exists for this mode -- this represents surely a problem when 32-bits
> types are wanted. My idead would then to decrease the long long size to
> be 32-bit.
>
> I have a patch for it, but I wanted to make sure that this construct is
> valid..
32-bit long long is not valid acording to the C standard, but since I
suspect there are many things in that mode that do not conform to the C
standard I expect one more thing would not cause any major problems.
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se
More information about the Gcc
mailing list