Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!swrinde!ucsd!ogicse!verdix!qtc!law From: law@qtc.UUCP (Larry Westerman) Newsgroups: comp.std.c Subject: Re: "expandable" structs with last element declared using [1] Message-ID: <1970@qtc.UUCP> Date: 19 Dec 89 21:14:09 GMT References: <463@cpsolv.UUCP> <477@longway.TIC.COM> Reply-To: law@qtc.UUCP (Larry Westerman) Organization: Quantitative Technology Corporation, Beaverton OR Lines: 27 In article <477@longway.TIC.COM> uunet!sq!msb (Mark Brader) writes: >The issue is the legality of: > > struct foo_struct { > int bar; > char baz[1]; > } *foo; > > foo = (struct foo_struct *) malloc(sizeof(struct foo_struct)+1); > foo->baz[1] = 1; /* error? */ > Although it is not relevant to the question of the legality of the structure declarations and usage such as the above example, it is worth noting that the Stepstone implementation of Objective C uses exactly this technique for the creation and manipulation of objects with indexed instance variables. "A man hears what he wants to hear and disregards the rest" Larry Westerman Quantitative Technology Corporation Beaverton OR 503-626-3081 ...verdix! or ...sequent! qtc!law -- "A man hears what he wants to hear and disregards the rest" Larry Westerman Quantitative Technology Corporation Beaverton OR 503-626-3081 ...verdix! or ...sequent! qtc!law