Size of structure containing char fields

Stephen Clamage steve at taumet.com
Sun Jul 29 07:43:16 AEST 1990


jimp at cognos.UUCP (Jim Patterson) writes:

>Sun's C compiler on a Sun 3 (with Sun OS 4.0) aligns structs on two
>byte boundaries. This is NOT an ANSI-compatible compiler, but I don't
>think that the ANSI standard will force them to change their ways.

As you noted, the ANSI standard allows padding between and at the end
of a struct.  The standard does not (and cannot) say anything about
where a data object must be located in memory.  Recall it is the struct
object, not the struct data type, which is being aligned.  That object
has an address, and whether one or more bytes preceding it in memory
are used or not is not business of the Standard.  In any event, no
portable program can access such bytes, even if they exist.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.std.c mailing list