| Deutsch English Français Italiano |
|
<vnph3i$13tcm$1@dont-email.me> 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: Andrey Tarasevich <noone@noone.net>
Newsgroups: comp.lang.c
Subject: Re: Struct Error
Date: Sun, 2 Feb 2025 20:35:59 -0800
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <vnph3i$13tcm$1@dont-email.me>
References: <vmr5gg$137jo$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 03 Feb 2025 05:36:03 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7c011d3426119c9c859f81b3672c6134";
logging-data="1176982"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IYkOM6vmF+wsQ7DUwnuLX"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:roPZ/n1qozWrUYDdRI+48eqYoQI=
In-Reply-To: <vmr5gg$137jo$1@dont-email.me>
Content-Language: en-US
Bytes: 2290
On Wed 1/22/2025 8:14 AM, bart wrote:
> 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?
C has always been very strict about completeness of the element type in
array declarations. The element type has to be complete, period.
Another manifestation of the same issue is demonstrated by the following
example
struct S;
void foo(struct S a[]) {}
The function parameter declaration is invalid in C sue to incompleteness
of `struct S`. Even though the declaration will be implicitly adjusted
anyway to
void foo(struct S *a) {}
and this adjusted version is perfectly valid the in C (despite
incompleteness of `struct S`), the language still rejects the original
variant.
C++ is more lenient in such contexts.
--
Best regards,
Andrey