🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1493

Re: Structure Member Padding

#1493
From: Peter da Silva
Date: Tue, 10 Jul 1990 15:35
28 lines
1248 bytes
In article <10420@ogicse.ogc.edu> daniels@ogicse.ogc.edu (Scott David Daniels) writes:
> 	struct first { char a; short s; };
> 	struct second{ char a; short s; char b; };
> 	struct third { char a; char b; short s; };
> I would like to be able to use the same layout for third and second, ...

struct head { char a; short b; };
struct first { char a; short b; long c; };
struct second { char a; short b; char c; };

You want to shove second.c between second.a and second.b, right?

copyhead(dest, src)
struct head *dest, *src;
{
	*dest = *src;
}

	struct first a;
	struct second b;

	copyhead(b, a);

You just clobbered b.c if you do that.
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.
<peter@ficc.ferranti.com>
Technical Details
Message-ID: <8LK4ID9@xds13.ferranti.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!rutgers!ucsd!pacbell.com!ames!sun-barr!newstop!texsun!texbell!ficc!peter
References: <1990Jul7.225141.12002@sq.sq.com> <13321@smoke.BRL.MIL> <10420@ogicse.ogc.edu> <13332@smoke.BRL.MIL>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!rutgers!ucsd!pacbell.com!ames!sun-barr!newstop!texsun!texbell!ficc!peter
From: peter@ficc.ferranti.com (Peter da Silva)
Newsgroups: comp.std.c
Subject: Re: Structure Member Padding
Message-ID: <8LK4ID9@xds13.ferranti.com>
Date: 10 Jul 90 15:35:33 GMT
References: <1990Jul7.225141.12002@sq.sq.com> <13321@smoke.BRL.MIL> <10420@ogicse.ogc.edu> <13332@smoke.BRL.MIL>
Reply-To: peter@ficc.ferranti.com (Peter da Silva)
Organization: Xenix Support, FICC
Lines: 24