[GRASS5] Re: G_fatal

Glynn Clements glynn.clements at virgin.net
Mon Apr 23 14:27:08 EDT 2001


Justin Hickey wrote:

> > > according to the programmers manual, G_fatal is defined as
> > >
> > > int G_fatal_error(char *);
> > >
> > > but according to gisdefs.h, it is
> > >
> > > int G_fatal_error(char *,...);
> > >
> > > I see that quite some code is relying on the second definition.
> > > Should it be changed in the progr. manual, or should everyone
> > > adopt the former?
> > >
> > > Same thing for G_warning().
> 
> Change the programmers manual. At some point, somebody wanted these
> functions to be able to accept variable arguments, and I see no reason
> (logical or software engineering wise) at this time to change them back
> to a single string. Besides, changing the manual is less work than
> changing several different places in the code.

A counterpoint is that, when G_fatal_error etc were changed to use
vsprintf (or similar), any code which did this:

	G_fatal_error(msg);

should have been changed to:

	G_fatal_error("%s", msg);

Note that gcc has the "format" attribute for printf()-like functions,
so G_fatal_error etc should probably be declared like:

#ifdef __GNUC_MINOR__
int G_fatal_error(char *,...) __attribute__ ((__noreturn__, __format__ (__printf__, 1, 2)));

This allows the compiler to detect mismatches between the format
string and the arguments.

-- 
Glynn Clements <glynn.clements at virgin.net>

---------------------------------------- 
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'



More information about the grass-dev mailing list