[Freeciv-Dev] Re: (PR#6285) rand_map_pos using native coordinates
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Jason Short wrote:
> Jason Short wrote:
[...]
>
>>+ native_to_map_pos(x, y, myrand(map.xsize), myrand(map.ysize));
>
> Except, with a macro form of native_to_map_pos, that will not work. At
> all. This new patch is better.
[...]
Using static global intermediate or passed in local working storage in
macros, allows one to define all arguments once and thus preserve the
function form compatibility.
As Jason says, One should never use indeterminate or volatile quantities
when using macros as a general rule, so the code fixes to use local
variable storage are correct in this case. But by the same token, if one
is switching from function to macro form and the function form has in the
past and probably will be the future the common code form, then there are
ways to make the macros compatible. Doing this anyway when possible can
never hurt.
In this case there is no problem no matter whether which of the two ways
one uses to provide working storage in this macro. Properly coding the
macro gives you this added compatibility and avoids such bugs for free.
Cheers,
RossW
=====
- [Freeciv-Dev] Re: (PR#6285) rand_map_pos using native coordinates,
rwetmore@xxxxxxxxxxxx <=
|
|