delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/15/02:33:30

Date: Mon, 15 Jun 1998 09:33:21 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Gili <sl AT psycode DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: enum problem
In-Reply-To: <bWLoegW7sFse-pn2-0JB8f0w8xHdR@portX61.lanzen.net>
Message-ID: <Pine.SUN.3.91.980615093258.9030D-100000@is>
MIME-Version: 1.0

On 14 Jun 1998, Gili wrote:

> "enum listing
> {
>   a=0x00,
>   b=0x02
> };
> 
>  function(listing input)
> {
> }
> "
> 
> 	Now, in my main() code I use "function(a|b)" and DJGPP reports that 
> my argument should be an "int" not a type "listing".

Please post code that you actually used.  The above snippet doesn't
compile ("parse error"), and while I can fix it, I'm unsure what did
your original code actually say, including the main function which you
didn't post at all.

You cannot hope for an accurate answer without posting the actual
source.

> There is no need to expand the size to an "int" because 
> any element of type "listing" when || (ORed) with another element will
> always remain within the confines of the listing-type.

This is certainly incorrect in general.  Your enumeration defines only
two possible values: 0 and 2.  Should it define 1 and 2, ORing them
would produce 3 which is invalid for this enumeration.

Also, I strongly suspect that the type of an expression "a|b" is an
int, regardless of its value.  (Could any ANSI guru please confirm
this?)

But please post the correct source, so that this problem could be
analyzed properly.

- Raw text -


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