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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
|
|