[ds6-devel] Re: [nc6-commit] nc6 ChangeLog,1.8,1.9 NEWS,1.7,1.8 README.Maint,1.9,1.10 configure.ac,1.22,1.23

Chris Leishman chris at leishman.org
Mon Jan 27 13:49:15 CET 2003


On Sat, Jan 25, 2003 at 03:42:38PM +0100, mauro at deepspace6.net wrote:
<snip>
> +* Do not to use global (non static) variables. In the 100% of cases there
> +  is a smarter way to achieve the same result you would get using global
> +  variables.

This is simply not true, as it is totally dependant on your definion of
smarter.  If you objective is to obtain officient access to a single
integer value, and avoid the unecessary function call overhead that
cannot be inlined, then the smart way is to use an extern int with a
macro interface to it.

> +* Try not to #define preprocessor constants when possible (especially constants
> +  that are used only inside a single module). The definition:
> +
> +  static const int VERY_VERBOSE_MODE = 0x02;
> +
> +  is much better than:
> +
> +  #define VERY_VERBOSE_MODE 0x02


I agree with this in most cases, but this situation I think it is
entirely appropriate.  There's absoulely no need for a static function
on something as commonly looked up as the verbosity, so defining it as
an extern int is efficient, and the macros provide a clean interface to
that.

Regards,
Chris


More information about the ds6-devel mailing list