Deutsch   English   Français   Italiano  
<vt9334$3hhr8$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: do { quit; } else { }
Date: Thu, 10 Apr 2025 19:36:21 +0100
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <vt9334$3hhr8$1@dont-email.me>
References: <vspbjh$8dvd$1@dont-email.me> <8634enhcui.fsf@linuxsc.com>
 <vsph6b$ce6m$5@dont-email.me> <86ldsdfocs.fsf@linuxsc.com>
 <20250406161323.00005809@yahoo.com> <86ecy5fjin.fsf@linuxsc.com>
 <20250406190321.000001dc@yahoo.com> <86plhodtsw.fsf@linuxsc.com>
 <20250407210248.00006457@yahoo.com> <vt15lq$bjs0$3@dont-email.me>
 <vt2lp6$1qtjd$1@dont-email.me> <vt31m5$2513i$1@dont-email.me>
 <vt3d4g$2djqe$1@dont-email.me> <vt3iqh$2ka99$1@dont-email.me>
 <868qoaeezc.fsf@linuxsc.com> <vt3oeo$2oq3p$1@dont-email.me>
 <86mscqcpy1.fsf@linuxsc.com> <vt48go$35hh3$2@dont-email.me>
 <86iknecjz8.fsf@linuxsc.com> <vt4del$3a9sk$1@dont-email.me>
 <86o6x5at05.fsf@linuxsc.com> <vt712u$1m84p$1@dont-email.me>
 <20250409170901.947@kylheku.com> <vt88bk$2rv8r$1@dont-email.me>
 <20250410092409.825@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 10 Apr 2025 20:36:21 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d4d34b1d7ed35db6137f2b3fedef19a1";
	logging-data="3721064"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19ltVWT2i6Wav+GAMdMN6sZ"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dMFe5sXPGOSkiU8Nhyuhxsbe8ns=
In-Reply-To: <20250410092409.825@kylheku.com>
Content-Language: en-GB
Bytes: 3833

On 10/04/2025 17:51, Kaz Kylheku wrote:
> On 2025-04-10, bart <bc@freeuk.com> wrote:

>> Do you agree with that? Or is there something more to making two types
>> be incompatible?
> 
> Tim: two fingerprints from the left hand index finger are from different
> humans if they are different.
> 
> You: do you agree with this, or is there more that can make
> two humans different?
> 
> Struct compatibility is determined by tag and content.

This is more nuanced. There is two structs being the same type or not, 
which a compiler can determine if they are in the same translation unit; 
no need to analyse tags or anything to figure that out, it's either the 
exact same type or not.

And there is two structs in two translation units which have separate 
definitions, which the compiler cannot compare, and which have to be 
compatible for the program to be valid. But the compiler cannot check that.

The example was like this:

module A:     typedef struct point {float a; float b;} Point;

module B:     typedef float length;
               typedef struct _tag {length x, y;} vector;

David Brown said:  "The two types are entirely compatible."

I said:            "Are they?"

Tim Rentsch said:  "No, they are not."

So DB and TR are disagreeing, but everyone is ignoring the fact that one 
of them is likely wrong, and sending /me/ off to read the standard!

TR went on to say: "The type names 'Point' and 'vector' name two
distinct types, and those types are not compatible, because
the two struct tags are different."

That does rather sound like it is the tags that are the sole deciding 
factor, which is when I started doing experiments.

ATEOTD, to share such a type across two or more translation units, means 
each one seeing its own definition of it. Nothing stops you having 
somewhat different versions of it, as I had above, so this part has to 
be taken on trust. This was part of my broader point that sharing 
non-linkage named entities across modules in C was ad hoc.