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

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 03:40:11
Reply-To: "Gili" <sl AT psycode DOT com>
MIME-Version: 1.0
Subject: Re: enum problem
Message-ID: <19980615072556700.AAA231@portC17.Generation.NET>

On Mon, 15 Jun 1998 09:33:21 +0300 (IDT), Eli Zaretskii wrote:

>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.

	The code I actually used is too big to include in here.. But
I'll make a compilable example:

"
  #include <stdio.h>

  enum lineType
{
  sLine=0x00,
  dLine=0x01,
  overwrite=0x02,
};

void saychoice(lineType choice)
{
  if (choice|dLine==dLine)
    printf("double line chosen");
  if (choice|overwrite==overwrite)
    printf("overwrite mode chosen");
}

int main()
{
  saychoice(sLine|overwrite);
}
"

>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.

	True..

>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?)

	I don't think so.. but I could be wrong ;)

Gili

- Raw text -


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