[GRASS-dev] Grass SVN in Android, display issue

Glynn Clements glynn at gclements.plus.com
Thu Sep 20 12:26:06 PDT 2012


Markus Neteler wrote:

> All GRASS 7 now compiles with the Android cross-compiler (after taking out
> XDR from configure[.in]) except for these two:

> make[4]: Entering directory `/home/neteler/grass70/raster/r.terraflow'

> arm-linux-androideabi-g++ ... -std=gnu++0x ...

NOTE ---------------------------^^^^^^^^^^^^

> direction.cpp: In function 'direction_type encodeDirectionMFD(const
> genericWindow<float>&, dimension_type, dimension_type, dimension_type,
> dimension_type)':
> direction.cpp:56: error: reference to 'is_void' is ambiguous

C++ Technical Report 1 (aka TR1) added the <type_traits> header, which
includes a struct template named "std::tr1::is_void". C++11 (formerly
known as C++0x) moved these features from the "std::tr1" namespace to
the "std" namespace.

Nine of the r.terraflow headers have "using namespace std", which
imports the entire "std" namespace into the current namespace. So
"is_void" is now already in use by the library.

This is why "using namespace std" is a bad idea. A C++ implementation
is allowed to add whatever it wishes to the "std" namespace, so using
"using namespace std" in application code means that every single
top-level name is a potential conflict with something from "std".

The other reason why this is a bad idea is that once you've imported
the entire "std" namespace into the current namespace, there is no way
to "un-import" a specific symbol. So either is_void() will need to be
renamed, or someone will have to fix the code to eliminate the "using
namespace std" (which, from experience, is likely to be a lot of
work).

Removing the "-std=gnu++0x" flag may work in the short term (or it may
not), but in the longer term I expect C++ compilers to make C++11 the
default dialect. Eventually, you may find that libraries start
requiring C++11 (using C++ templates means that a lot of code has to
go into header files, so if a library wants to use C++11 features, its
headers will require C++11, which means any program using those
headers has to be compiled as C++11).

> make[4]: Entering directory `/home/neteler/grass70/raster/r.viewshed'

> statusstructure.cpp: In function 'double
> find_max_gradient_in_status_struct(StatusList*, double, double, double)':
> statusstructure.cpp:295: error: reference to 'is_empty' is ambiguous

Ditto; In C++11, <type_traits> also defines std::is_empty.

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


More information about the grass-dev mailing list