Mail Archives: djgpp/1998/03/01/20:15:48
Noam Rotem wrote:
> Maybe it's trivial, but why is there a data type which its size can be
> different in
> different compilers? I refer to 'int'. Why can it be 2 or 4 bytes,
> depending on the
> implementation? What's the logic?
The logic is that different compilers do things differently. In
particular, the size of `int' is best left to the compiler because
compilers will be able to do work in their native word size much faster
than any other. So it makes sense to have `int' be this. If you have
specific size requirements, use `short' or `long'. The limitations
dictated by ANSI C are:
1. char must be at least 8 bits.
2. short must be at least 16 bits.
3. long must be at least 32 bits.
4. char must be no larger than short, which must be no larger than
int, which must be no larger than long.
--
Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
Alcyone Systems / http://www.alcyone.com/max/
San Jose, California, United States / icbm://+37.20.07/-121.53.38
\
"I've got the fever for the / flavor of a cracker"
/ Ice Cube
- Raw text -