Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Two different Results between C and C++ Date: Tue, 02 Jun 2020 11:51:54 -0700 Organization: None to speak of Lines: 38 Message-ID: <87ftbdwbat.fsf@nosuchdomain.example.com> References: <4ccefcca-1bde-44f7-a7b7-694476dacc64@googlegroups.com> <87k10pwi1c.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="2b720ada2beb0fb974b5f9a3cdd89767"; logging-data="21394"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188k0GLCH4RiDMsGZ23bKO+" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:RY5x/uyUuCULKUmuTk/wRqbj7Z4= sha1:rPhRibX6FoPurWLXF1uTDo4lyso= Xref: csiph.com comp.lang.c:152606 Lew Pitcher writes: > On June 2, 2020 12:26, Keith Thompson wrote: >> mark.bluemel@gmail.com writes: >> [...] >>> (1!=1) is a C boolean value, which is an int. >> >> Not exactly. C does have a boolean type, called _Bool (or bool if >> you've included . But equality and comparison operators >> yield values of type int, not of type bool. > > I believe that Mark was trying to indicate the distinction between how C++ > interprets (1!=1) and how C interprets it. > > In the C++ case, (1!=1) results in a boolean type, holding a boolean value > (or so Mark implies; I don't know C++) > > In the C case, (1~=1) results in an int type (which Mark does point out), > holding value that indicates the truth or falsehood of the assertion (a > "boolean" value). > > Perhaps Mark will clarify his post for us. Yes, what Mark said is mostly correct. My quibble is about the phrase "C boolean value". I suppose you could say that 0 (of type int) is a "C boolean value", but it would make more sense to apply that term to a value of the C type _Bool. In C90, where _Bool didn't yet exist, I wouldn't have much of a problem referring to 0 as a "C boolean value". And just to add to the frivolity, the macros "false" and "true" in expand to 0 and 1, respectively, which are of type _Bool, not int. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */