Integer sizes; storage classes.
Richard O'Keefe
ok at edai.UUCP
Fri Jun 15 06:15:32 AEST 1984
G'day.
I've just come across a C compiler for M6809s, and was rather shocked
to find that its authors had decided to make
char = 8 bits
short = 8 bits
int = 8 bits
long = 16 bits
I thought I could rely on "int i = 1000;".
As I've said in an earlier message, my reading of K&R is that "int" has
to be big enough to hold the difference between the addresses of the
ends of the largest array the programmer is allowed to declare.
Whether you agree or not, this selection would seem to make it pointlessly
difficult to port C programs to/from other compilers.
What do other opinionated people think about this?
The compiler has a nice feature: there is a "readonly" storage class.
readonly declarations must be initialised, and the data are placed in
the text area. Is this part of some new standard? There should be a
distinction between "readonly int x = 1;" and "static readonly int x = 1;"
but that would seem to mess up the syntax (worth it).
Speaking of storage classes, I know that in some compilers I *can* say
extern <declaration>;
.... ....
<real declaration for same thing>;
but there's a compiler for a 32-bit midi which generates bad loader
code for this. Clearly a bug, but is the bug failure to spot my abuse
of the language, or bad code generation for a correct program?
More information about the Comp.lang.c
mailing list