RISC Machine Data Structure Word Alignment Problems?

Woodrow Baker woody at rpp386.cactus.org
Sun Feb 11 16:34:11 AEST 1990


In article <328 at ctycal.UUCP>, ingoldsb at ctycal.UUCP (Terry Ingoldsby) writes:
> In article <1648 at skye.ed.ac.uk>, richard at aiai.ed.ac.uk (Richard Tobin) writes:

> This discussion, IMHO, is pointless.  The C compilers work just fine the way
> are (or at least the ones I am familiar with).  I don't think some of the
> people discussing this realize the implications of what they propose.

Wrong.  It depends on what you do.  I happen to do programming dealing
with industrial controllers.  Specificaly, I maintain a compiler, editor
downloader, and monitor package used to program Eagle Signal Controls
EPTAK series industrial controllers.  The code that I work on runs under
MS-DOS.  I have to do things like reach out over the network, and read
data structures out of the remote controllers.  These structures for the
most part, are a mix of byte and word fields.  I then have to parse through
them, and isolate the parts.  Structures are the obvious way to do this.
BUT, the @#$% compiler choses to pad byte or char values out to ints.
This, obviously screws up the data structure access to the retrieved
values.  I have wound up doing things that I am not proud of, like unions,
monkeying around with pointers to the structures such that they don't
point to where they should, but to some offset other than the first byte
of the structure etc.  Yes, I could chose to use an array, but it is clearer
to use standard field names, (at least standard for the EPTAK controlers)
to access these data fields.


Cheers
Woody



More information about the Comp.lang.c mailing list