Path: utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!ukc!edcastle!aiai!richard From: richard@aiai.ed.ac.uk (Richard Tobin) Newsgroups: comp.std.c Subject: Re: Representation Clauses Message-ID: <4125@skye.ed.ac.uk> Date: 13 Feb 91 16:46:54 GMT References: <91042.160311KKEYTE@ESOC.BITNET> Reply-To: richard@aiai.UUCP (Richard Tobin) Organization: AIAI, University of Edinburgh, Scotland Lines: 29 In article <91042.160311KKEYTE@ESOC.BITNET> KKEYTE@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@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin