lkml.org 
[lkml]   [2005]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: share/private/slave a subtree - define vs enum
From
Date
I wasn't aware anyone preferred defines to enums for declaring enumerated 
data types. The practical advantages of enums are slight, but as far as I
know, the practical advantages of defines are zero. Isn't the only
argument for defines, "that's what I'm used to."?

Two advantages of the enum declaration that haven't been mentioned yet,
that help me significantly:

- if you have a typo in a define, it can be really hard to interpret the
compiler error messages. The same typo in an enum gets a pointed error
message referring to the line that has the typo.

- Gcc warns you if a switch statement doesn't handle every case. I often
add an enumeration and Gcc lets me know where I forgot to consider it.

The macro language is one the most hated parts of the C language; it makes
sense to try to avoid it as a general rule.

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

\
 
 \ /
  Last update: 2005-07-08 18:37    [W:0.073 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site