Sujet : Re: remark on defining size of basic types
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 05. Apr 2024, 00:39:00
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uunvah$15vot$1@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 4/4/24 13:04, Michael S wrote:
On Thu, 4 Apr 2024 12:02:16 -0400
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
On 4/4/24 09:15, Janis Papanagnou wrote:
...
Since I remember C had always just defined a '<=' (or '>=') relation
between the unsized basic integral data types.
...
He meant sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long
long)
That's not actually the case. In the above, you are not using <= as the
C operator, but simply to indicate relative order over multiple items; I
will do the same. What is specified is equivalent to the following
LONGLONG_MIN <= LONG_MIN <= INT_MIN <= SHORT_MIN <= SCHAR_MAX
SCHAR_MAX <= SHORT_MAX <= INT_MAX <= LONG_MAX <= LONGLONG_MAX
UCHAR_MAX <= USHORT_MAX <= UINT_MAX <= ULONG_MAX <= ULONGLONG_MAX
SCHAR_MAX <= UCHAR_MAX
INT_MAX <= UINT_MAX
LONG_MAX <= ULONG_MAX
LONGLONG_MAX <= ULONGLONG_MAX
The sizes are not required to be in the same order as the maximum
values, nor in the opposite order of the minimum values. If they were in
a different order, it would imply a lot of padding bits, which would be
very odd, but not prohibited.