Mail Archives: djgpp/1998/06/15/03:34:21
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 -