Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!ginosko!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!agate!shelby!csli!poser From: poser@csli.Stanford.EDU (Bill Poser) Newsgroups: comp.lang.c Subject: Re: sizeof a struc field Message-ID: <10767@csli.Stanford.EDU> Date: 24 Oct 89 23:08:09 GMT References: <7710@microsoft.UUCP> <680011@hpmwjaa.HP.COM> <11404@smoke.BRL.MIL> Sender: poser@csli.Stanford.EDU (Bill Poser) Reply-To: poser@csli.stanford.edu (Bill Poser) Organization: Center for the Study of Language and Information, Stanford U. Lines: 25 I am curious as to when someone would want to take sizeof(((T *) 0)->member). If you need to know the size of a structure member, you can always consult the structure definition, discover that member is, say, of type "int", and write sizeof(int). If you want to allow for future changes in the member's type, use the preprocessor and make both the definition and the argument to sizeof macros, e.g. #define INTEGRAL int #define REAL double struct foo{ INTEGRAL a; REAL b; }; Then you get the size of the a member as: sizeof(INTEGRAL) Perhaps one can argue that this isn't the most perspicuous thing to do, but it seems easy enough that I am curious as to how outlawing the null pointer construction can be seen as reducing C functionality in any significant way. Bill