long_int vs int byte sizes

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Apr 7 14:42:00 GMT 2014


On Apr  7 08:16, Eric Blake wrote:
> On 04/07/2014 02:47 AM, Corinna Vinschen wrote:
> 
> > 
> > There's no standard which restricts the sizes of the datatypes in
> > that way.  There's only this rule to follow:
> > 
> >   sizeof (char) <= sizeof (short) <= sizeof (int) <= sizeof (long)
> 
> Well, there IS the C rule that sizeof(char)==1, and also that char holds
> >= 8 bits, short holds >= 8 bits, int holds >= 16 bits, long holds >= 32
> bits.  There is also a POSIX rule that CHAR_BITS==8 (so while C allows a
> 9-bit or 32-bit char [and yes, such machines exist, although rare],
> POSIX does not allow that).

Apart from POSIX, where is that defined?  The old K&R rules only defined
the sizes of the datatypes in comparison to each other, but it never
defined minimum sizes.  If you have a 7 bit machine and you only use
ASCII, you can be happy ever after.  And while it *suggested* that short
< long, it didn't demand it.

> POSIX does not allow that).  But in general, on most modern porting
> platforms, 'long' is a redundant type - it will either be equal in size
> to 'int' (typical for a 32-bit machine) or to a 'long long' (typical for
> a 64-bit machine); it only mattered on 16-bit machines which are now
> museum pieces.

Xstormy16?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20140407/993c8021/attachment.sig>


More information about the Cygwin mailing list