delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/13/09:23:44

Sender: crough45 AT amc DOT de
Message-Id: <97Aug13.151644gmt+0100.17061@internet01.amc.de>
Date: Wed, 13 Aug 1997 14:16:48 +0100
From: Chris Croughton <crough45 AT amc DOT de>
Mime-Version: 1.0
To: max AT alcyone DOT com
Cc: djgpp AT delorie DOT com
Subject: Re: Why does sizeof give me...

Erik Max Francis wrote:

>As the chief ANSI C advocate on this newsgroup, I should point out that
>ANSI does not say anything about the size of the fundamental integer types
>(short, int, long), except that short is no larger than int and int is no
>larger than long, and short is at least 16 bits and long is at least 32.
>(What's interesting is that these latter two requirements are hidden
>rather well in the standard.)

I have used one compiler (VAX, possibly?) which had short = int = long
and
all 32 bit.  Fortunately, char was still 8 bit (but it needn't be - some
machines have 9 bit chars).

The only portable way is to do it yourself - either by breaking longer
variables up into chars or in ASCII.  Especially since you can't rely
on any byte ordering scheme (I gather there are some machines where a
long is held in memory as bytes 2, 1, 4 and 3 or something similar, not
even a reversible format).

Isn't this all in the FAQ?  Or was it one of the other C newsgroup FAQs?

Chris C

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019