Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: finding offset of a member in C structures Message-ID: <16247@smoke.brl.mil> Date: 23 May 91 20:06:21 GMT References: <22103@paperboy.OSF.ORG> <16236@smoke.brl.mil> <22138@paperboy.OSF.ORG> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 14 In article <22138@paperboy.OSF.ORG> dbrooks@osf.org (David Brooks) writes: -In article <16236@smoke.brl.mil>, gwyn@smoke.brl.mil (Doug Gwyn) writes: -|> But that's merely a design botch, because in order to ask for the offset -|> of a structure member one HAS to have a particular structure type in mind; -|> to make any use of the information one has to have a suitable pointer at -|> hand. -This is probably dragging the point out too far, but no. The XtOffset -macro is used to initialize a static array-of-struct. There is no reason -to have a variable of the struct type in scope. But the programmer can easily MAKE one simply by casting the polymorphic array member type to whatever is being assumed for each use of the offset macro in the initializer. The "handle" needed is present, albeit not in the final form you want.