[GRASS-dev] unknown reference to G__gisinit

Glynn Clements glynn at gclements.plus.com
Tue May 8 18:38:54 EDT 2012


Markus Neteler wrote:

> > extern "C"
> > {
> > #include <grass/gis.h>
> > }
> >
> > and it worked, just in case other people finds the same problem.
> 
> Glad you found it. I have added a note to
> http://grass.osgeo.org/wiki/GRASS_and_C++
> 
> (please expand that Wiki page)

If it's considered desirable to be able to use GRASS from C++, the
headers' contents should be bracketed with:

	#ifdef __cplusplus
	extern "C" {
	#endif

	...

	#ifdef __cplusplus
	}
	#endif

Without the 'extern "C" ...' qualification, C++ assumes that functions
have C++ linkage, meaning that the parameter types are embedded in the
symbol name (C++ allows function overloading, where multiple functions
can have the same name provided that they have different parameter
types).

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


More information about the grass-dev mailing list