Path: utzoo!attcan!telly!nebulus!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: Zero Length Arrays Allowed in C Standard? Message-ID: <1989Dec14.152212.11590@druid.uucp> Date: 14 Dec 89 15:22:12 GMT References: <2298@jato.Jpl.Nasa.Gov> <11715@smoke.BRL.MIL> <480@codonics.COM> <1989Dec2.210042.12668@twwells.com> <8129@cg-atla.UUCP> <1989Dec12.110042.29290@gdt.bath.ac.uk> Reply-To: darcy@druid.UUCP (D'Arcy J.M. Cain) Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 53 In article <1989Dec12.110042.29290@gdt.bath.ac.uk> exspes@gdr.bath.ac.uk (P E Smee) writes: > >One reason I haven't seen given yet is to provide a marker for the end >of an entity. I could use such a beast (more or less) as follows >(example slightly simplified)... > > struct fred { > struct fred * last; > struct fred * next; > long offset; > int thing; > ... bunch of more data stuff > char end_marker[0]; /* MUST BE LAST IN STRUCTURE */ > }; > > .... > > bzero (&fred.offset, &fred.end_marker - &fred.offset); > This looks like a good idea but I don't understand why it must be the last element. How about the following: struct fred { struct fred * last; long offset; int thing; ... bunch of more data stuff char end_marker[0]; struct fred * next; }; Then your bzero still works but on a chunk of the structure internal to the structure. You could also use the address of next but the above should still work (assuming of course an ANSI standard different from what we have.) Of course I am assuming that this mythical construct would act as it does in assembler where; LABEL1: LABEL2: dw 0 evaluates both LABEL1 and LABEL2 as pointing to the same memory location. This is fun. Maybe we need a comp.lang.mythical :-) -- D'Arcy J.M. Cain (darcy@druid) | Thank goodness we don't get all D'Arcy Cain Consulting | the government we pay for. West Hill, Ontario, Canada | No disclaimers. I agree with me |