Article View: comp.std.c
Article #2416Re: Representation Clauses
From: Doug Gwyn
Date: Wed, 13 Feb 1991 21:49
Date: Wed, 13 Feb 1991 21:49
31 lines
1952 bytes
1952 bytes
In article <91042.160311KKEYTE@ESOC.BITNET> KKEYTE@ESOC.BITNET (Karl Keyte) writes:
>How flexible are ANSI? I.e. is 'C's standardisation fixed?
Yes, the standard was approved by ANSI in late 1989 and is not
expected to undergo revision (apart from possible ISO addenda,
which are not attempting to make changes of the sort that you
suggest) for several years to come.
>I feel that 'C' is missing data alignment representation clauses in
>structures. I would like to be able to do something like:
> struct ALIGN_TEST
> {
> int a at 0;
> char b at 4;
> float c at 8;
> }
>in order to force the offset of the elements. This then enables
>structures to provide truly portable messages on machines with
>different structure alignments. For example, the above structure
>is not the same on a Sun-3 and a Sun-4 (Sparc).
Ideas along these lines were submitted during preparation of the
ANSI C standard, and were rejected by the committee. There are
at least two significant problems with the idea, one being that
it is an innovation, not existing practice, the other being that
it doesn't provide the portable message structure that you think
it does. You can insert padding by use of dummy fields, but the
most difficult issues for binary data interchange between
heterogeneous architectures are much deeper than mere alignment
of fields. Sun invented the XDR protocols to deal with them, for
one concrete example worthy of study.
Technical Details
Message-ID:
<15187@smoke.brl.mil>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!adm!smoke!gwynReferences:
<91042.160311KKEYTE@ESOC.BITNET>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: Representation Clauses Message-ID: <15187@smoke.brl.mil> Date: 13 Feb 91 21:49:29 GMT References: <91042.160311KKEYTE@ESOC.BITNET> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 31