Deutsch English Français Italiano |
<vms4km$19srg$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: James Kuyper <jameskuyper@alumni.caltech.edu> Newsgroups: comp.lang.c Subject: Re: Struct Error Date: Wed, 22 Jan 2025 20:05:25 -0500 Organization: A noiseless patient Spider Lines: 40 Message-ID: <vms4km$19srg$1@dont-email.me> References: <vmr5gg$137jo$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Date: Thu, 23 Jan 2025 02:05:27 +0100 (CET) Injection-Info: dont-email.me; posting-host="31c72b4efd976f4522d1d4024f2c9062"; logging-data="1373040"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19s+dzvGPEQzEmGaH2Omhzu/Owq5w6ti6Y=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:r6zCTQbI/gIZdYfMiTH+ZpXQBi0= In-Reply-To: <vmr5gg$137jo$1@dont-email.me> Content-Language: en-US Bytes: 2492 On 2025-01-22, bart <bc@freeuk.com> 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)[]; > }; 6.7.6.2p2: "The element type shall not be an incomplete or function type." I have many draft versions of the C standard. n2912.pdf, dated 2022-06-08, says in 6.7.2.1.p3 about struct types that "... the type is incomplete144) until immediately after the closing brace of the list defining the content, and complete thereafter." Therefore, struct scenet is not a complete type until the closing brace of it's declaration. However, that sentence disappeared in n3047.pdf, dated 2022-08-04. Can anyone tell me why it was removed? With it gone, I'm not sure it is still considered an incomplete type. Ignoring for the moment the fact that it's not permitted, why do you want to do that? In C code, people usually use pointers to the first element of an array rather than pointers to arrays. However, it sometimes is a good idea to have a pointer to an array, because that makes the length of the array part of the pointer type, which can be used to check the validity of the code that uses that pointer to access the elements of the array. But in this case, the length of the array is unspecified, so there's no such benefit.