Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!paperboy!osf.org!dbrooks From: dbrooks@osf.org (David Brooks) Newsgroups: comp.lang.c Subject: Re: finding offset of a member in C structures Message-ID: <22138@paperboy.OSF.ORG> Date: 23 May 91 14:34:54 GMT References: <22051@paperboy.OSF.ORG> <16220@smoke.brl.mil> <22103@paperboy.OSF.ORG> <16236@smoke.brl.mil> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 23 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. The table information is used by a generic procedure compiled separately, to fill in information from an outside database using code that is probably itself non-portable- but-invariably-works. In practice, there are local variables of the same type later in the source file, but they don't *have* to be there. They too could be separately compiled. As I said, I agree it's a design botch, and it's nice to have ANSI define offsetof, but it is all done with good intentions, in the interests of information hiding. -- David Brooks dbrooks@osf.org Systems Engineering, OSF uunet!osf.org!dbrooks