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:44:57 -0800 Organization: None to speak of Lines: 20 Message-ID: References: <35c56d5c-ff4a-46b5-9166-e88353bf62ce@googlegroups.com> 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/vdGe1hMvGOcYjZQk97Vbt" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:tsm3IiqHT/lRT/ffh5f+/471jFk= sha1:W3vyP6w3+lcsSfMZjZl+nc5RhqE= Xref: csiph.com comp.lang.c:102326 Alla _ writes: [...] > But as I have spent quite a while trying to implement offsetof(), I > would like to finish that one too, to find my mistakes, correct them > and make the code work. Are you trying to *implement* offsetof(), or are you trying to *use* offsetof()? If you're trying to implement it (i.e., write your own version), then (a) it's not necessary, since all conforming C implementations provide it in , and (b) there is no completely portable way to implement it (which is part of why it's defined in the standard library). -- 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"