Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Optimizing the code: way to reduce if, else if-s within the loop? Date: Sun, 22 Jan 2017 07:47:10 -0800 Organization: None to speak of Lines: 21 Message-ID: References: <35c56d5c-ff4a-46b5-9166-e88353bf62ce@googlegroups.com> <87efzvxm7h.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="888facdcfaaf0dacdc56e3b90fcf0c54"; logging-data="24027"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/bzArm8BIPqZkiHDCUSBON" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:u80HBHbl0xAMa0Ysl5HBHglnUvE= sha1:9sDD+kF9HPt6iXjCKzGmF09gpsE= Xref: csiph.com comp.lang.c:102327 BartC writes: > On 22/01/2017 13:23, Ben Bacarisse wrote: >> BartC writes: [...] >>> This seems a common way of implementing it: >>> >>> #define offsetof(s,m) (int)&(((s *)0)->m) >> >> That would be wrong so I'm sorry to hear it's a common way. > > What's wrong with it? offsetof yields a result of type size_t. This macro yields a result of type int. (It's also non-portable, but in a way that's likely to work under most implementations.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"