| delorie.com/archives/browse.cgi | search |
| From: | Martin Ambuhl <mambuhl AT earthlink DOT net> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: enum - Why does true == false? |
| Date: | Fri, 17 Sep 1999 00:11:53 -0400 |
| References: | <HbrhNzeq9qsy9UvyzT4fDeX4Lrnh AT 4ax DOT com> |
| X-Posted-Path-Was: | not-for-mail |
| X-Accept-Language: | en |
| X-ELN-Date: | 17 Sep 1999 04:09:54 GMT |
| X-ELN-Insert-Date: | Thu Sep 16 21:15:28 1999 |
| Organization: | Nocturnal Aviation |
| Lines: | 65 |
| Mime-Version: | 1.0 |
| NNTP-Posting-Host: | dialup-209.246.88.220.newyork2.level3.net |
| Message-ID: | <37E1BF89.907E43B2@earthlink.net> |
| X-Mailer: | Mozilla 4.61 [en] (Win95; U) |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Carl Hover wrote:
>
> Why does this program print "true == false" when compiled with djgpp
> v2.01, and "true != false" when compiled with Borland C++ 3.1? Are
> enum constants ill-defined during preprocessing?
Try replacing your code with the following and see if it gives you a
clue:
#include <stdio.h>
int main(void)
{
enum {
false, true
};
#if defined(true)
printf("true is defined\n");
#elif !defined(true)
printf("true is not defined\n");
#endif
#if defined(false)
printf("false is defined\n");
#elif !defined(false)
printf("false is not defined\n");
#endif
#if true == false
printf("true == false\n");
#endif
#if true != false
printf("true != false\n");
#endif
return 0;
}
>
> #include <stdio.h>
>
> int main(void)
> {
> enum {false, true};
>
> #if true == false
> printf("true == false\n");
> #endif
>
> #if true != false
> printf("true != false\n");
> #endif
>
> return 0;
> }
--
Martin Ambuhl mambuhl AT earthlink DOT net
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |