🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #128

Re: Character arrays in structures and address alignment -- any standard?

#128
From: Steve Clamage
Date: Mon, 27 Jul 1992 18:36
20 lines
993 bytes
duane@anasazi.com (Duane Morse) writes:

|  struct {
|    char a[3];
|    char b[2];
|  } x;

|On the 5 different Unix machines in our building, 'b' always starts 3
|bytes after 'a'; the compiler is smart enough to know that it is both
|legal and proper to leave the start of 'b' on an odd byte boundary.

|But is that a standard or a requirement?

The Standard allows arbitrary padding between fields and after the
last field.  You cannot rely on the offset of member 'b' being the
same on different implementations.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Technical Details
Message-ID: <1992Jul27.183622.794@taumet.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
References: <1992Jul26.225252.4487@anasazi.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
From: steve@taumet.com (Steve Clamage)
Subject: Re: Character arrays in structures and address alignment -- any standard?
Message-ID: <1992Jul27.183622.794@taumet.com>
Organization: TauMetric Corporation
References: <1992Jul26.225252.4487@anasazi.com>
Date: Mon, 27 Jul 1992 18:36:22 GMT
Lines: 20