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: Mon, 23 Jan 2017 08:44:36 -0800 Organization: None to speak of Lines: 27 Message-ID: References: <2e2405b7-23f8-4572-b71f-f4011e1bc284@googlegroups.com> <0lv98clfgb14i3nidh80crekhsst6uehps@4ax.com> <45f31c8d-4b4f-4833-9f1b-4dbb591e874a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="df81394688a029c3b8d8507037788c4c"; logging-data="27870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pm3xhRd5l5jsOP5tklOhs" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:h2XlBNgt6VpWuKe+lhkyDCLXrVM= sha1:rEEX2RK10lKJGhX+tOJjNdNHyto= Xref: csiph.com comp.lang.c:102376 Alla _ writes: > On Sunday, January 22, 2017 at 10:08:21 PM UTC+3, Barry Schwarz wrote: >> On Sun, 22 Jan 2017 08:16:07 -0800 (PST), Alla _ >> wrote: >> >> >On Sunday, January 22, 2017 at 6:47:47 PM UTC+3, Barry Schwarz wrote: >> >> On Sun, 22 Jan 2017 03:24:39 -0800 (PST), Alla _ >> >> > > What still is not clear to me is why the value of the offset of the second > member is 8, and not 4, if the first member has an int type, and on my > machine an int is 4 bytes. Is it due to the way all structure members > are being aligned? All other offsets are 8 because all other members > have type double. Here is a small test program that I wrote to see > the offsets of some structure, and I don't understand the result: [snip] This is probably irrelevant to what you're working on, but it's covered in the comp.lang.c FAQ, , questions 2.12 and following. -- 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"