Re: [Freeciv-Dev] Programing style
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
> Since in C, enums really do correspond directly to integers,
> I don't see a real problem in converting between the two,
> though it would be good practice to use the explicit enum types
> where feasible. Whether its worth converting stuff to use
> unions I'm not sure.
The problem I encountered when I tried that approach (for a patch
to introduce city build queues) was that C doesn't allow union values
to be distinquished by type. This
union build_item {
enum unit_type unit;
enum improvement_type improvement;
};
is useless because it's impossible to tell whether a build_item is
actually a unit or a improvement. At least, that's what K&R told me.
--
Reinier
|
|