Sujet : Re: Struct Error
De : richard.nospam (at) *nospam* gmail.invalid (Richard Harnden)
Groupes : comp.lang.cDate : 22. Jan 2025, 21:08:07
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vmrj78$15uf3$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 22/01/2025 16:14, bart wrote:
struct vector;
struct scenet;
struct vector {
double x;
double y;
double z;
};
struct scenet {
struct vector center;
double radius;
struct scenet (*child)[];
};
The error is:
error: array type has incomplete element type 'struct scenet'
struct scenet (*child)[];
^~~~~
Is there any way to fix this, or is it not possible?
(This comes from generated code. Idiomatic C would use a T* here rather than T(*)[], but that is not an option. Other compilers like tcc, DMC and mine have no problem with it.)
Clang says: definition of 'struct scenet' is not complete until the closing '}'
Can you loose the parens? 'struct scenet *child[];' is fine (so long as it's the last element).
Otherwise, 'struct scenet **child;' or 'struct scenet *child' - depending on whether you mean 'children' or 'next';