Path: utzoo!utstat!jarvis.csri.toronto.edu!mailrus!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: news.software.b Subject: Re: Cnews on System V/AT: "expression causes compiler loop" Message-ID: <480@mwtech.UUCP> Date: 23 Nov 89 09:29:12 GMT References: <3056@splut.conmicro.com> <1989Nov20.181839.1546@utzoo.uucp> <1676@crdos1.crd.ge.COM> <1063@east.East.Sun.COM> <1989Nov21.17513 Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 20 In article <1989Nov21.175136.3418@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: [lines deleted] >If we could have assumed an ANSI implementation, the whole issue would go >away, because we wouldn't have to supply our own offsetof(). Did you ever think about the following alternative to offsetof(): 1) Instead of offsetof() use #defined constants. 2) When 'make'ing the programm, *automatically* generate an #include-file with the required #defines by 2a) compile and run a programm, which calculates the offset by taking the difference of the struct.component-s adress and the struct-s adress, after casting both to char* IMHO this should be portable within all flavours of C-Compilers. BTW: I myself did not invent this approach, but I've forgotten where I read it (in some really good book about C-Programming - don't like to walk to my board of C books now :-) ).