Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2001:
[Freeciv-Dev] Re: Profiling Civserver again
Home

[Freeciv-Dev] Re: Profiling Civserver again

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Thue Janus Kristensen <thue@xxxxxxxxxxxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Profiling Civserver again
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Sun, 29 Jul 2001 18:16:07 -0400

Double underbar as in "__blort" is reserved to the OS headers which you can
verify by looking in /usr/include.

No user code is supposed to use single underbars "_FOOlish" for variable
names, so they are "safe" in user header macros.

Be careful of overlapping macro arguments, i.e. passing an _x0 arg into
another
macro, but usually you can even get away with namespace collisions between
macros. However, users that peek and use the _variables within the begin
and end blocks of the current split macro flavour do so at their own risk,
i.e. should be careful to check that there isn't an overriding local
context due to nesting. 

Some of the current map.h macros actually have code in the end blocks, i.e.
the user or another macro could unintentionally modify things in dangerous
ways. It is slightly safer to try to put all the internal stuff in a single
block at the start where no one can get at it at least for one iteration
block sequence, and on a new iteration there is usually only a subset of
local variables that are dangerous.

The mapgen.c examples from a couple emails ago tried to follow these
published and unpublished standards.

Cheers,
RossW
=====

At 11:03 PM 01/07/29 +0200, Thue Janus Kristensen wrote:
>You should name the internal macro variable "border" something to be sure
there are
>no name clashes. ie
>
>{
> int border = 0;
>
>   adjc_dir_iterate {
>      if (A=B)
>         border++;
>   } adjc_dir_iterate_end;
>
> printf("%d\n", border);
>}
>
>Would give the poor user quite a headache.
>
>I like the idea of prefixing with "_", as seen in Ross W. Wetmore's patches.
>
>(note that you don't have to do this with the arguments.)
>
>-Thue




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