Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] Re: simple historian agent
Home

[Freeciv-Dev] Re: simple historian agent

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: nikodimka <nikodimka@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: simple historian agent
From: Raimar Falke <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sun, 28 Mar 2004 10:18:32 +0200

On Sat, Mar 27, 2004 at 09:43:15AM -0800, nikodimka wrote:
> > Make the return type const:
> >   const struct tile *sha_tile_recall(int x, int y)
> > so that no other code changes the struct fields.
> > 
> 
> Hm. This raised a question (I hope this is not just my ignorance ;)
> ).  *all* unit related functions in freeciv accept just "struct
> unit*" types.  compilation -W* flags are very strict so when I would
> try to call for example
> 
> unit_activity_text(sha_unit_recall()) 
> 
> there would be a warning:
> 
> warning: passing arg 1 of `unit_activity_text' discards qualifiers from 
> pointer target type
> 
> and compilation would fail.
> 
> the proper type for unit_activity_text and a huge amount of all other 
> functions
> not const char *unit_activity_text(struct unit *punit);
> but const char *unit_activity_text(const struct unit *punit);
> since these functions do not change the incoming unit argument.
> 
> so I see three possible solutions:
> 
> a) to change signature of counless freeciv functions
> b) to make compilation warnings less strict 
> c) to make the return type of simple historian agent not const
> d) to use (sturct union*) casts right around each sha_unit_recall call which 
> is "c)" but uglier.

Ohh. Didn't thought of this. Yes you are right. I really want to have
a) in the long run. But c) is ok for now.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "At the beginning of the week, we sealed ten BSD programmers
  into a computer room with a single distribution of BSD Unix.
  Upon opening the room after seven days, we found all ten programmers 
  dead, clutching each other's throats, and thirteen new flavors of BSD."


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