Subject: Use of sizeof()
To: None <r.black@ic.ac.uk>
From: Gordon W. Ross <gwr@mc.com>
List: current-users
Date: 07/11/1995 20:16:43
> From: Robert Black <r.black@ic.ac.uk>
> Date: Tue, 11 Jul 1995 10:47:11 +0100

> I have a question for anyone with intimate knowledge of the K&R C standard.
What standard?  There is only a de-facto "K&R C standard"...
(As far as I have ever heard anyway, you have ANSI C or no standard.)

> There is some code in NetBSD (generic SCSI is one place) which makes
> assumptions about the alignment of structs. This takes the form of assuming
> that structs are only aligned to the alignment of their largest data type.
[...]
> Which is broken: the NetBSD code or the compiler?

Both could be considered "correct" and some systems (i.e. SVR4)
deal with this using the following where packing is required:

#pragma pack 
struct
{
	short a;
	short b;
	short c;
} foo;
#pragma nopack

Of course, then the system needs its own special compiler...

Gordon Ross