[GRASS-dev] Vect_*_fatal_error()

Glynn Clements glynn at gclements.plus.com
Sat Nov 12 06:07:40 EST 2011

Martin Landa wrote:

> the vector library still uses in GRASS7 GV_FATAL_EXIT/PRINT/RETURN
> defines, see Vect_set_fatal_error() for details. It was introduced in
> r10426.
> I know that this topic "G_fatal_error() and exit() call" has been
> discussed several times in the past. The GRASS libraries has been
> designed for Unix-like modules, which just starts, do processing and
> terminates. This absolutely acceptable reason why G_fatal_error()
> should call exit() when fatal_error appears. On the other hand I still
> think that the programmer should have some possibility to avoid
> calling exit() on G_fatal_error() of course on his/her own risk.
> Anyway this option should be there with BIG warning at least but it
> should be there...
> Please review the attach patch which moves Vect_*_fatal_error() to the gislib.

The G_set_fatal_error() concept is broken. Code which calls
G_fatal_error() expects it to be fatal. Other code isn't entitled to
have a say in that.

You appear to have overlooked this:

	void G_fatal_error(const char *, ...) __attribute__ ((format(printf, 1, 2)))
	    __attribute__ ((noreturn));

I'm talking about the "__attribute__ ((noreturn))" part. That is
absolutely fundamental to the behaviour of G_fatal_error() and cannot
be changed.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list