delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/15/12:21:07

From: sl AT psycode DOT com (sl)
To: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Cc: "DJGPP mailing list" <djgpp AT delorie DOT com>
Date: Mon, 15 Jun 98 12:26:09
Reply-To: "Gili" <sl AT psycode DOT com>
MIME-Version: 1.0
Subject: Re: enum problem
Message-ID: <19980615161158063.AAA190@portD58.Generation.NET>

On Mon, 15 Jun 1998 17:51:07 +0300 (IDT), Eli Zaretskii wrote:

>There are several problems here.  First, compiling this as a C program 
>didn't produce the warning you were complaining about.  So I suspect you 
>compiled this as a C++ program, which you should have mentioned.  I'm 
>quite sure that C++ produces an int from sLine|overwrite, and then 
>objects to passing an int to a function which expects an enum.  But I'm 
>not knowledgeable about C++ enough to tell for sure.  Anybody?

	This is a C++ program.. I don't understand why C++ would act
differently from C on this point since this 'feature' is derived from C
in the first place.

>Second, what exactly did you expect from an expression like this:
>
>	 if (choice|dLine==dLine)
>
>At least in C, the == operator has higher precedence than the | operator, 
>so this is parsed as "if (choice | (dLine == dLine))", which is hardly 
>what you wanted to say...  Even if C++ changes that, I suggest to use 
>explicit parentheses.

	I was unaware of that.. What I meant was "if ((choice|dLine) ==
dLine)"

Gili

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019