Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: sizeof a struc field Message-ID: <11338@smoke.BRL.MIL> Date: 19 Oct 89 10:07:51 GMT References: <7710@microsoft.UUCP> <11086@smoke.BRL.MIL> <131@dtoa3.dt.navy.mil> <11316@smoke.BRL.MIL> <1234@crdos1.crd.ge.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 23 In article <1234@crdos1.crd.ge.COM> davidsen@crdos1.UUCP (bill davidsen) writes: >What the original poster wanted was the size of a field within a struct. >He proposed using: > sizeof(((struct mytype *)0)->field) >which involves using a null values pointer. The value of this under pcc >compilers is the size of the field within a struct mytype. You interpret >the standard to forbid this. No, what I say is that the Standard does not require that it work as the programmer seems to expect it to. That's not the same thing. A conforming implementation is free to make it work if it so chooses. It is also free to not make it work. >Do you also interpret the standard to forbid: > int fieldlen = sizeof(head->a); Of course not. It does forbid int fieldlen = sizeof(((struct mytype*)0)->a). As I keep telling you, it is NOT an issue about sizeof! It's an issue about ->. So long as you persist in trying to determine this by reading the sizeof specs in the Standard, you'll never understand what I'm saying.