Representation Clauses
Richard Tobin
richard at aiai.ed.ac.uk
Thu Feb 14 03:46:54 AEST 1991
In article <91042.160311KKEYTE at ESOC.BITNET> KKEYTE at ESOC.BITNET (Karl Keyte) writes:
>How flexible are ANSI? I.e. is 'C's standardisation fixed?
There's no chance of changing the current ANSI standard. In ten years
or so, there might be another one.
> struct ALIGN_TEST
> {
> int a at 0;
> char b at 4;
> float c at 8;
> }
You can solve this for most machines by doing something like this:
struct {
union {int a; char x[4];} a;
union {char b; char x[4];} b;
union {float c; char x[4];} c;
} s;
Of course, if sizeof(int) is greater than 4 you're going to lose. And
you have to say s.a.a instead of s.a.
-- Richard
--
Richard Tobin, JANET: R.Tobin at uk.ac.ed
AI Applications Institute, ARPA: R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin
More information about the Comp.std.c
mailing list