[GRASS5] Draft Programmer's Manual available

Andreas Lange Andreas.Lange at Rhein-Main.de
Sun May 28 09:53:35 EDT 2000

Markus Neteler wrote:
> Note for all:
> It seems a set of functions returns 0 on success, other 1.
> Should this be consistent?
> In case you find further "book-bugs", please let me know.
> Layout work is proceeding...

Hi Markus, hi Rich, hi all,

there is no general consistency in GRASS if a function returns 0 or 1 on
success. The majority of functions return 0 on error and 1 on success,
but there are many which return 0 on success and a negative value on

The only way to find out is to RTS (read the source). It is not possible
to change this, because all modules must be changed for checking the new
values. It is more or less a general design thing of the whole library. 

Some functions use an int return value not only to signal a
success/error condition, but return an index to a list or a
filedescriptor (have no GRASS examples at hand), these functions return
a negative value on error, as the index or fd could be zero. 

I think some programmers derived the return values from c stdio
functions, which return EOF (defined as -1) on error and 0 on success.
This is usual practice in c. 
The code of the libraries and modules mixes 0 (numerical zero) with NULL
(the null pointer), which i personally find confusing too. Some modules
use 0 (numerical zero) interchangebly with `\0` (string terminator),
which is also confusing. Many modules use -1, but mean EOF. Although
there are in most cases no compile or run-time errors with this, it is
not a good practice and i think everyone writing new code should be
encouraged to use this consistently. Yes, and there are many many
problematic typecasts or missing typecasts, so that gcc or a linter
complains about incompatible pointer types.

hope that did not confuse you even more,


Andreas Lange, 65187 Wiesbaden, Germany, Tel. +49 611 807850
Andreas.Lange at Rhein-Main.de, A.C.Lange at GMX.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