Xref: utzoo comp.lang.c++:4869 comp.lang.c:22381 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!pilchuck!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: Time to standardize "true" and "false" Message-ID: <2152@dataio.Data-IO.COM> Date: 29 Sep 89 18:35:29 GMT References: <12070@cit-vax.Caltech.Edu> <8862@etana.tut.fi> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 23 In article <8862@etana.tut.fi> pl@etana.tut.fi (Lehtinen Pertti) writes:, by wen-king@cit-vax.Caltech.Edu (King Su): << #define bool(a) (!!(a)) < Then suddenly just behind the corner cames C-compiler from < ACME-corporation and realizes '!!a' -< negation of negation is < same as original -< we can optimize it away. If a compiler thought that (!!a) == (a), then it is a compiler bug. < Nice, isn't it. And too real too. If you run up against such wretchedness, you can do this: #if ACME_C #define bool(a) ((a) != 0) /* if desperate try ((a)?1:0) */ #else #define bool(a) (!!(a)) #endif I have a copy of K&R which I believe is a first printing. It *clearly* states that ! is to return 1 or 0. Not -1. Not implementation defined. Using ! is portable. If it doesn't work with your C, treat it like any other compiler bug. If anyone knows of a *current* C compiler that has a problem with this, please email me. I'm curious!