Article View: comp.std.c++
Article #1816Re: true/false literal std question
From: Robert Mollitor
Date: Tue, 22 Aug 1995 22:53
Date: Tue, 22 Aug 1995 22:53
44 lines
1931 bytes
1931 bytes
In article <MATT.95Aug22012318@Austern> mfinney@inmind.com writes: > > In <ROBERT.95Aug21123621@mirage.visix.com>, robert@Visix.COM (Robert Mollitor) writes: > >But if the preprocessor doesn't "understand" 'true' and 'false', then what > >stops someone from defining > > > > #define true 1 > > #define false 0 > > That does not work correctly because if you have a function... > > void foo(bool); > void foo(int); > > and you call... > > foo(true) > > the wrong function will be called. > I'm sorry. I was too cryptic. I agree with you that it is a bad thing for the reason you mention. I would expect a C++ preprocessor to disallow the #defines in the first place (as it maybe should disallow #defines to any keyword?). If this is a C incompatibility issue, so be it. #ifndef __cplusplus #define true 1 #define false 0 #endif is easy enough. robt -- Robert Mollitor robert@visix.com Visix Software Inc. ...!uupsi!visix!robert [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<ROBERT.95Aug22183221@mirage.visix.com>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<40jjuu$qnk@mujibur.inmind.com> <4135i2$744@engnews2.Eng.Sun.COM> <ROBERT.95Aug21123621@mirage.visix.com> <MATT.95Aug22012318@Austern>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: robert@Visix.COM (Robert Mollitor) Newsgroups: comp.std.c++ Subject: Re: true/false literal std question Date: 22 Aug 1995 22:53:44 GMT Organization: Visix Software, Inc. Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <ROBERT.95Aug22183221@mirage.visix.com> References: <40jjuu$qnk@mujibur.inmind.com> <4135i2$744@engnews2.Eng.Sun.COM> <ROBERT.95Aug21123621@mirage.visix.com> <MATT.95Aug22012318@Austern> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: mirage In-Reply-To: mfinney@inmind.com's message of 22 Aug 1995 09:23:18 GMT Content-Length: 972 X-Lines: 40 Originator: clamage@taumet