"expandable" structs with last element declared using [1]

Larry Westerman law at qtc.UUCP
Wed Dec 20 08:14:09 AEST 1989


In article <477 at 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



More information about the Comp.std.c mailing list