[GRASS-dev] [GRASS-SVN] r60703 - in grass/trunk: display/d.vect general/g.gisenv gui/wxpython/animation lib/python/temporal raster/r.colors raster/r.external raster/r.in.bin raster/r.mapcalc raster/r.neighbors raster/r.out.bin raster/r.quant raster/r.resamp.filter raster/r.series raster/r.series.accumulate raster/r.series.interp raster/r.stats.quantile vector/v.colors vector/v.external.out

Glynn Clements glynn at gclements.plus.com
Wed Jun 11 03:43:21 PDT 2014


Huidae Cho wrote:

> Maybe, we can use variadic macros in C99 to remove the first name argument.

GRASS doesn't require C99. In general, we try to keep the hard
dependencies to a bare minimium, particularly in core functionality
such as libgis.

In any case, the <stdarg.h> requirement for an explicit first argument
isn't a significant problem. The functions would never be called with
less than two arguments.

In the worst case, it complicates the implementation slightly, as we
can't simply iterate over all of the arguments using va_arg(), but
have to treat the explicit argument separately. That can be handled
like:

	void G_option_exclusive(void *first, ...)
	{
	    void *opt = first;
	    va_start(ap, first);
	    for (;;) {
	        process(opt);	// search for opt in options/flags
	        opt = va_arg(ap, void*);
	        if (!opt)	// NULL terminator
	            break;
	    }
	    va_end(ap);
	}

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list