Deutsch English Français Italiano |
<87semf4pw5.fsf@nosuchdomain.example.com> 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: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: do { quit; } else { } Date: Thu, 10 Apr 2025 15:23:38 -0700 Organization: None to speak of Lines: 48 Message-ID: <87semf4pw5.fsf@nosuchdomain.example.com> References: <vspbjh$8dvd$1@dont-email.me> <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> <87wmbs45oa.fsf@nosuchdomain.example.com> <vt8hdp$333f0$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 11 Apr 2025 00:24:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="c7132c9dc01e9da84b004e8ef39b7407"; logging-data="4160109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Jg5D83jV6jyKcbmgpohgC" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:JqTZh1I2nJCf1lysy+hf0V3G27Q= sha1:2TagI+JdEDpTTp1ORtpKpSEwOnM= Bytes: 3627 bart <bc@freeuk.com> writes: > On 10/04/2025 12:28, Keith Thompson wrote: >> bart <bc@freeuk.com> writes: >> [...] >>> Someone, not anyone but the all-knowing Tim, said: "and those types >>> are not compatible, because the two struct tags are different." >>> >>> Do you agree with that? Or is there something more to making two types >>> be incompatible? >> I don't recall the exact discussion > > It stems from this, a reply from DB dated: "Tue, 8 Apr 2025 16:50:56 > +0200". (About half way down there is some quoted code of mine.) > > It concerned two struct types in different translations units, which > needed to be compatible for the test program to work corectly. > > I said they were compatible enough. David said they were entirely > compatible. Tim said "No they are not". Three different opinions. Either David or Tim was right; I don't much care which. You were wrong. There is no such thing as "compatible enough"; two types either are compatible or are not compatible. I won't speculate on what you might have meant by "compatible enough". The most reliable way to determine whether two types are compatible is to read the standard see whether they satisfy the requirements. If you have not done so, nothing you say about C type compatibility is of any interest. A good way to determine whether a compiler treats two types as compatible is to define pointers to both of them and try assigning them, then compiling the code in conforming mode. For example : type1 *ptr1 = NULL; type2 *ptr2; ptr2 = type1; If type1 and type2 are compatible, then type1* and type2* are compatible, and there should be no diagnostic for the assignment. If they're not compatible, then type1* and type2* are not compatible *and* there is no implicit conversion betwen them, and a conforming compiler must give a diagnostic. Don't forget to run the compiler in conforming mode. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */