🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2420

Re: Representation Clauses

#2420
From: Richard Tobin
Date: Wed, 13 Feb 1991 16:46
29 lines
1393 bytes
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
Technical Details
Message-ID: <4125@skye.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!ukc!edcastle!aiai!richard
References: <91042.160311KKEYTE@ESOC.BITNET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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