Deutsch   English   Français   Italiano  
<86iknecjz8.fsf@linuxsc.com>

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: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: do { quit; } else { }
Date: Tue, 08 Apr 2025 16:27:23 -0700
Organization: A noiseless patient Spider
Lines: 87
Message-ID: <86iknecjz8.fsf@linuxsc.com>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Wed, 09 Apr 2025 01:27:25 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b047b0586914e6e160c0016b929ac37f";
	logging-data="3440901"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19SejI1h9MWpjHrX6aWweMzx5kg9yDZLQw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:JyY1F2KSiLNuk52U14DhtHussGs=
	sha1:+oLLV4ARbj3oFIKQ1iiVZC8zvPc=
Bytes: 4433

bart <bc@freeuk.com> writes:

> On 08/04/2025 22:18, Tim Rentsch wrote:
>
>> bart <bc@freeuk.com> writes:
>>
>>> On 08/04/2025 18:32, Tim Rentsch wrote:
>>>
>>>> bart <bc@freeuk.com> writes:
>>>>
>>>>> On 08/04/2025 15:50, David Brown wrote:
>>>>>
>>>>>> On 08/04/2025 13:35, bart wrote:
>>>>>>
>>>>>>> But this need not be the case.  For example this is module A:
>>>>>>>
>>>>>>> --------------------------
>>>>>>>    #include <stdio.h>
>>>>>>>
>>>>>>>    typedef struct point {float a; float b;} Point;
>>>>>>>
>>>>>>>    float dist(Point);
>>>>>>>
>>>>>>>    int main(void) {
>>>>>>>    Point p = {3, 4};
>>>>>>>    printf("%f\n", dist(p));
>>>>>>>    }
>>>>>>> --------------------------
>>>>>>>
>>>>>>> And this is module B that defines 'dist':
>>>>>>>
>>>>>>>
>>>>>>> --------------------------
>>>>>>>    #include <math.h>
>>>>>>>
>>>>>>>    typedef float length;
>>>>>>>    typedef struct _tag {length x, y;} vector;
>>>>>>>
>>>>>>>    length dist(vector p) {return sqrt(p.x*p.x + p.y*p.y);}
>>>>>>> --------------------------
>>>>>>>
>>>>>>> The types involved are somewhat different, but are compatible
>>>>>>> enough for it to work.
>>>>>>
>>>>>> The two types are entirely compatible.
>>>>>
>>>>> Are they?
>>>>
>>>> No, they are not.  The type names 'Point' and 'vector' name two
>>>> distinct types, and those types are not compatible, because
>>>> the two struct tags are different.
>>>>
>>>> Because the two types are not compatible, even just calling the
>>>> function dist() is undefined behavior.
>>>
>>> I get an incompatible error (from the example you snipped) even when I
>>> remove both struct tags.
>>>
>>> I can't use the same struct tag in the same scope as one will clash
>>> with the other.  But if I have the second in an inner scope, then I
>>> again get the error.
>>
>> If you want to make a point or ask a question about C code,
>> SHOW THE CODE.  And show all of it.  Don't make people guess
>> by showing only some of the code or by giving just a description.
>
> I'm showing the code but you keep snipping it!  [...]

No, I don't.  Don't be so obtuse.  I included the code I was
originally commenting on, in my first followup.  My comment about
showing code was about your second posting.  Let me repeat the two
important paragraphs (quoted above) taken from that posting:

>>> I get an incompatible error (from the example you snipped) even when I
>>> remove both struct tags.

The phrase "even when I remove both struct tags" describes code, it
doesn't show the code.

>>> I can't use the same struct tag in the same scope as one will clash
>>> with the other.  But if I have the second in an inner scope, then I
>>> again get the error.

The phrase "if I have the second in an inner scope" describes code,
it doesn't show the code.

And don't accuse me of something I haven't done.