From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4A5CB1C2.2000805@tecmav.com> Date: Tue, 14 Jul 2009 18:26:42 +0200 From: Adriano Verardo User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 SeaMonkey/1.1.12 MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> References: <4A5C8F93.6090603@tecmav.com> <7144845a3c658a8194be95e64d69486f@coraid.com> In-Reply-To: <7144845a3c658a8194be95e64d69486f@coraid.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [9fans] C compiler question Topicbox-Message-UUID: 203f5e96-ead5-11e9-9d60-3106f5b1d025 erik quanstrom wrote: >> The point is how to compute the offset(s) of the last field at compile / >> run time. >> > > the offset of the last field is not in question. i believe you mean the size? > It's really the same info. struct { ..... // total sizeof = 100 int B[..]; }A; offset(B) = 100, &(A.B[7]) == address(A) + 100 + 7*sizeof(int). The compiler accept the dirty but legal expression A.B[-3] because it can compute the address (or the offset with respect the beginnig of "A") of the B "-3" cell. But in this case struct { ..... // total sizeof = 100 struct B B; }A; with B declared (just named), how 8c could determined the address of A.B.x ? To accept the above definition of A, say in a global .h, means that every .c should include the definition of B. They could be - legally - different, so generating different offsets of "x" with respect A in the same program. >> I prefer to have only the tricky but standard "char x[0]" tails. >> > > i'd prefer not to have them, either. but it's too late for that. > > :-) And what about char x[...] and x[2] == 2[x] :-) :-) >> Your patch will be included in the next distribution CD ? >> > > no. i haven't submitted it yet. > > - erik adriano