Is it allowed to take the address of an object on the right hand-side of its definition, as happens in foo()
below:
typedef struct { char x[100]
The question has already been answered, but for reference, it doesn't make much sense. This is how you would write the code:
typedef struct { char x[100]; } chars;
chars make (void) {
chars c;
/* init c */
return c;
}
void foo(void) {
chars b = make();
}
Or perhaps preferably in case of an ADT or similar, return a pointer to a malloc
:ed object. Passing structs by value is usually not a good idea.