Flagging unused function arguments

Frank Warmerdam fwarmerdam at GMAIL.COM
Mon Jan 24 09:59:00 EST 2005


On Mon, 24 Jan 2005 09:53:43 +0100, Petter Reinholdtsen <pere at hungry.com> wrote:
> In the process of fixing warnings, a large class of warnings are
> unused arguments to functions.  A common way to fix this is to flag
> unused argument as such, letting gcc now that these arguments are
> supposed to be unused.  There are two parts to this method.  First, a
> define in some common header file (normally config.h):
>
>   /* Macro for declaring function arguments unused. */
>   #if defined(__GNUC__)
>   #  define UNUSED __attribute__((unused)) /* Flag variable as unused */
>   #else /* not __GNUC__ */
>   #  define UNUSED
>   #endif

Petter,

I am not adverse to adding the above style definition and using it as
you have suggested.

> Next, one used this flag when a function is defined, flagging the
> unused arguments:
>
>   static int loadLabel(labelObj *label, mapObj *map UNUSED)
>   {
>      ...
>   }
>
> The flag can be placed in front of or after the variable.  Personally,
> I prefer to place it after the variable.
>
> My question is where I should put this define?  I notice there is no
> config.h generated by configure (perhaps it should be changed?), so I
> am trying to guess which of the other header files are fit for such
> define.  Perhaps a new headerfile "common.h" is better?  Or perhaps
> starting to generate "config.h" is the best option?  What do you
> think?

I would suggest adding it in map.h near the MS_DLL_EXPORT definition.
I realize there are include files that don't include map.h (such as cgiutil.h
and mapprimitive.h) but I would suggest we just modify them to include
map.h.   This would also help get rid of multiple definitions of MS_DLL_EXPORT
as we have now (in map.h and cgiutil.h for instance).

Are there any objections from other developers from me making such changes
in 4.5?

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-dev mailing list