Deutsch English Français Italiano |
<867c6m3sxx.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch <tr.17687@z991.linuxsc.com> Newsgroups: comp.lang.c Subject: Re: Struct Error Date: Wed, 22 Jan 2025 23:11:54 -0800 Organization: A noiseless patient Spider Lines: 35 Message-ID: <867c6m3sxx.fsf@linuxsc.com> References: <vmr5gg$137jo$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 23 Jan 2025 08:11:55 +0100 (CET) Injection-Info: dont-email.me; posting-host="5251420bc9371d9685ddcd1ded05bea1"; logging-data="1611017"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xqoTTtVOqHsUzK1aIQ8WGImQBQxV0ZR0=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:8NnetXbFASJeVbVzAOqvgvNr41I= sha1:GxhvhfgJsOwLRRdSW3ahAcomwkE= Bytes: 1879 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.