Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: sizeof a struc field Summary: What you meant, not what you said Message-ID: <1503@crdos1.crd.ge.COM> Date: 27 Oct 89 16:46:40 GMT References: <7710@microsoft.UUCP> <11316@smoke.BRL.MIL> <7685@cdis-1.uucp> <1003@cirrusl.UUCP> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: GE Corp R&D Center Lines: 17 In article <1003@cirrusl.UUCP>, dhesi@sunseeker.UUCP (Rahul Dhesi) writes: | sizeof ((type *)x)->member If x is not a pointer type I'm sure you mean sizeof ((type *)&x)->member ^ This is the portable way to do it, but some compilers will complain mightily about casting the address of a non-struct to a struct. The most portable way would be to have a dummy variable of the pointer to struct type (or use one if you anready have it). -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon