Mail Archives: djgpp/1997/07/15/10:53:21
Hello Eric.
> Hmm? 32 bit ints are different? That might be the problem.
> I used GDB and got an 8 digit or so number, and I was wondering how
> that could fit in an int. I always thought an int was 2 bytes on any
> compiler. Is a char still one byte? What are the other types? Maybe
> I should go look them up. Thanks for the help.
Well, as far as I remember (AFAIR?? :-), the specification of the type
sizes are this:
sizeof(char) <= sizeof(short int) <= sizeof(int) <= sizeof(long int)
The ANSI C-standard (there hasen't been made an official ANSI C++
standard yet - has there??) says nothing about the sizes of the
datatypes, only which ones are equal to or bigger (or in other words -
definately not smaller) than the others.
The actual sizes are implementation dependant, only the size relations
between the types a settled. This means that you could actually run your
head against a compiler which uses 96 bit chars :-), and it could as
well be ANSI C compliant as long as the other size relations still holds
(and any other things defined in the standard of course :-).
Yours faithfully.
Finn Kettner.
PS. This comes from the top of my head, and as such is more than very
likely to include a lot of errors :-).
- Raw text -