Article View: comp.std.c++
Article #1759Re: true/false literal std question
From: William E. Aitken
Date: Mon, 21 Aug 1995 15:11
Date: Mon, 21 Aug 1995 15:11
44 lines
2120 bytes
2120 bytes
In article <416oev$71f@mujibur.inmind.com>, <mfinney@inmind.com> wrote:
>
>I personally find it very annoying to use 'true' in one location and 'True'
>or 'TRUE' or 'tRUe' somewhere else -- differing only in capitalization but
>having the same intent and semantic definition. This is absolutely (in my
>opinion) unnecessary confusion that such a situation would engender. And
>it would ALSO tend to promote bugs. The preprocessor would bitch if 'true'
>were used, but the compiler would NOT bitch if 'True' were used because
>of the standard promotion rules.
>
Unfortunately, it's even worse than that. The preprocessor will
NOT complain about true. This can cause some rather unpleasant surprises,
for example:
#define MC68000
#ifdef MC68000
#define BIGENDIAN true
#endif
#if BIGENDIAN
int main(int argc, char **argv)
{
printf("Hello, world!\n);
return 0;
}
#else
int main(int argc, char **argv)
{
printf("Surprise!\n);
return 1;
}
#endif
--
William E. Aitken | Formal verification is the
email: aitken@halcyon.com | future of computer science ---
Snail: 8500 148th Ave NE #H1026 Redmond WA | Always has been, always will be.
===============================================================================
[ 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:
<419fk4$75b@news1.halcyon.com>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<4167na$nv9@engnews2.Eng.Sun.COM> <416oev$71f@mujibur.inmind.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: aitken@coho.halcyon.com (William E. Aitken) Newsgroups: comp.std.c++ Subject: Re: true/false literal std question Date: 21 Aug 1995 15:11:40 GMT Organization: Northwest Nexus, Inc. - Professional Internet Services Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <419fk4$75b@news1.halcyon.com> References: <4167na$nv9@engnews2.Eng.Sun.COM> <416oev$71f@mujibur.inmind.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: coho.halcyon.com Content-Length: 1258 X-Lines: 40 Originator: clamage@taumet