August Karlstrom said:
A variable of an enumerated type holds a "symbol" (C as opposed to
e.g. Lisp don't have "real" symbols). The value of the "symbol" is
(usually) not important to the client. A typical example is
enum animal {CAT, DOG, BIRD};
...
enum animal x = BIRD;
If you aim for clarity, my suggestion to use `#define' is preferable.
Hint: If you were to give your anonymous type
enum { cols = 8, rows = 8 };
a name, what would that be? Moreover, e.g.
enum foo { cols = 8, rows = 8};
...
enum foo x = rows;
doesn't make sense.
Actually, using an enum declaration to declare named constants is a
fairly common idiom. It's arguably an abuse of the feature, but it's
also the best way to create a symbolic constant (at least one of type
int). A macro, though it's perfectly usable with care, brings in all
the problems of the preprocessor (lack of scope, counterintuitive
results in expressions, etc). A const declaration creates a read-only
variable, not a true constant.
So for the above, I might write:
enum { COLS = 8 };
enum { ROWS = 8 };
By separating COLS and ROWS into two separate declarations, this
avoids giving the impression that I'm creating a meaningful type.
Putting the names in all-caps makes it clear that they're constants.
And to answer your question, I wouldn't give such a type a name;
creating a type is just a side effect of what's intended to be a
constant declaration.