Re: Use enum to declare errno values

From: moreau francis
Date: Wed Nov 23 2005 - 11:05:50 EST

--- Nikita Danilov <nikita@xxxxxxxxxxxxx> a écrit :
> No it shouldn't. Following is a perfectly legal thing to do in C:
> enum side {
> };
> int foo(int x)
> {
> if (x & 0x1)
> return LEFT;
> else
> return RIGHT;
> }
> This is not C++ fortunately.
> Nikita.

hmm, are you sure that debuggers will tell you that foo returns LEFT/RIGHT but
not any integer value ?

I just give a try and unfortunately you seem to be wrong here:

(gdb) s
foo (x=1) at enum_test.c:8
8 if (x & 0x1)
(gdb) finish
Run till exit from #0 foo (x=1) at enum_test.c:8
0x0804837c in main (argc=1, argv=0xbfe14dc4) at enum_test.c:17
17 return foo(1);
Value returned is $1 = 0

But we needn't change all function prototypes that return an errno value in one
shot because as you said we can mix enum and int.


Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at