Sujet : Re: Struct Error
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 23. Jan 2025, 08:11:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <867c6m3sxx.fsf@linuxsc.com>
References : 1
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
bart <
bc@freeuk.com> writes:
Gcc 14.1 gives me an error compiling this code:
>
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.)
The code shown violates a constraint in the C standard, because
the element type of the array declarator is an incomplete type
at the point the 'child' member is declared, so a diagnostic
is required.