Complete.Org: Mailing Lists: Archives: freeciv-dev: June 1999:
Re: [Freeciv-Dev] Programing style
Home

Re: [Freeciv-Dev] Programing style

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Reinier Post <rp@xxxxxxxxxx>
Cc: Freeciv developers <freeciv-dev@xxxxxxxxxxx>
Subject: Re: [Freeciv-Dev] Programing style
From: Andy Black <ablack@xxxxxxxxxxxxxx>
Date: Sat, 12 Jun 1999 13:52:14 -0600 (MDT)

On Fri, 11 Jun 1999, Reinier Post wrote:

> > 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;
> };

I belive that you look at is_building_unit to determine wether you are
building a building or unit, and then look at build_item.unit or
build_item.building to find the value.  The queue would probably consist
of struct including a pointer/pointers to other items in the queue and the
union listed above.

Andy Black

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


[Prev in Thread] Current Thread [Next in Thread]