Re: Struct Error

Liste des GroupesRevenir à cl c 
Sujet : Re: Struct Error
De : noone (at) *nospam* noone.net (Andrey Tarasevich)
Groupes : comp.lang.c
Date : 03. Feb 2025, 05:35:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vnph3i$13tcm$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
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

Date Sujet#  Auteur
22 Jan 25 * Struct Error38bart
22 Jan 25 +* Re: Struct Error2Kaz Kylheku
22 Jan 25 i`- Re: Struct Error1Ben Bacarisse
22 Jan 25 +- Re: Struct Error1Richard Harnden
22 Jan 25 +- Re: Struct Error1Lawrence D'Oliveiro
23 Jan 25 +* Re: Struct Error31James Kuyper
23 Jan 25 i+* Re: Struct Error3m137
23 Jan 25 ii+- Re: Struct Error1Tim Rentsch
23 Jan 25 ii`- Re: Struct Error1James Kuyper
23 Jan 25 i+- Re: Struct Error1Tim Rentsch
23 Jan 25 i`* Re: Struct Error26bart
23 Jan 25 i +* Re: Struct Error9BGB
24 Jan 25 i i`* Re: Struct Error8bart
24 Jan 25 i i +- Re: Struct Error1BGB
24 Jan 25 i i +* Re: Struct Error4David Brown
24 Jan 25 i i i`* Re: Struct Error3Kaz Kylheku
24 Jan 25 i i i +- Re: Struct Error1bart
25 Jan 25 i i i `- Re: Struct Error1James Kuyper
24 Jan 25 i i `* Re: Struct Error2James Kuyper
25 Jan 25 i i  `- Re: Struct Error1bart
24 Jan 25 i +* Re: Struct Error5Lawrence D'Oliveiro
24 Jan 25 i i`* Re: Struct Error4bart
24 Jan 25 i i `* Re: Struct Error3Lawrence D'Oliveiro
24 Jan 25 i i  +- Re: Struct Error1Keith Thompson
24 Jan 25 i i  `- Re: Struct Error1bart
24 Jan 25 i +- Re: Struct Error1James Kuyper
24 Jan 25 i `* Re: Struct Error10Michael S
26 Jan 25 i  `* Re: Struct Error9bart
26 Jan 25 i   +- Re: Struct Error1Michael S
27 Jan 25 i   +* Re: Struct Error2Kaz Kylheku
27 Jan 25 i   i`- Re: Struct Error1bart
29 Jan 25 i   `* Re: Struct Error5Tim Rentsch
29 Jan 25 i    +* Re: Struct Error2bart
30 Jan 25 i    i`- Re: Struct Error1Tim Rentsch
29 Jan 25 i    `* Re: Struct Error2Richard Damon
29 Jan 25 i     `- Re: Struct Error1Tim Rentsch
23 Jan 25 +- Re: Struct Error1Tim Rentsch
3 Feb 25 `- Re: Struct Error1Andrey Tarasevich

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal