Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: how about sizeof(((type *)1)->member) ? Message-ID: <11440@smoke.BRL.MIL> Date: 30 Oct 89 13:37:07 GMT References: <1989Oct27.141015.20578@talos.uucp> <2550111@hpisod2.HP.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 12 In article <2550111@hpisod2.HP.COM> decot@hpisod2.HP.COM (Dave Decot) writes: >OK, fine. My what a tiresome language. Here: > sizeof(((struct foo *)(sizeof(struct foo)))->member) The constraint is not imposed by the language, but rather by the available computer architectures. Since C permits the programmer to get "close" to the architecture, these warts become more visible than in some higher-level languages. The reason offsetof() is specified as part of a conforming implementation in the C Standard is to keep programmers from trying to concoct their own non-portable invention for this.