Messages in this thread | | | From | Denis Vlasenko <> | Subject | Re: Use enum to declare errno values | Date | Sun, 4 Dec 2005 15:10:18 +0200 |
| |
On Friday 02 December 2005 18:56, Vadim Lobanov wrote: > On Fri, 2 Dec 2005, Bill Davidsen wrote: > > > Coywolf Qi Hunt wrote: > > > > > > That is a bad bad style. It should be `#define FOO 123' if you have to > > > write it. > > > > > > It's also hard to see what the confusing bar is "if you are looking at > > > file.c alone". > > > > > > enum is worse than typdef. Don't you see why we should use `struct > > > task_struct', rather than `task_t'? > > > > > > Introducing enum alone can't solve the problems from bad macro usage > > > habits. Actually, it's not anything wrong with macros, it's > > > programers' bad coding style. > > > > Using enum doesn't *solve* problems, it does *allow* type checking, and > > *prevent* namespace pollution. Use of typedef allows future changes, if > > you use "struct XXX" you're stuck with it. > > You're not stuck with anything onerous in this case. Namely, > > If you have "enum XXX" and you want to go to "enum YYY", then... > sed 's/enum XXX/enum YYY/g' > If you have "struct XXX" and you want to go to "struct YYY", then... > sed 's/struct XXX/struct YYY/g' > If you have "enum XXX" and you want to go to "struct YYY", then... > This is a big change, and should be done with care anyway. If struct YYY > happens to be large, then suddenly you can get all sorts of nifty stack > overflows.
I was talking about _anonymous enums_. There you do not have enum XXX, you have only named constants of type int:
enum { CONST = 12345 };
CONST is of type "int" here. -- vda - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |