[GRASS-dev] Compiling r.viewshed and r.terraflow with C++11

Glynn Clements glynn at gclements.plus.com
Tue Dec 10 02:41:18 PST 2013

Vaclav Petras wrote:

> So my question is, was this fixed in the time of [1]? It is not clear from
> the discussion.


> If not, what is the right fix?

The right fix is to remove all occurrences of "using namespace std;",
then fix the (probably hundreds) of errors which arise, either by
using qualified names (e.g. std::vector) or by adding "using"
statements for individual names (e.g. "using std::vector;").

[Note that iostream uses templates, so it might matter which approach
is taken. A qualified name forces the use of a specific function (or
type, etc), whereas a "using" statement adds the name as a fallback
but argument-dependent lookup takes priority.]

A more comprehensive fix would be to simply not accept code written in
C++. It's a deceptively complex language, and writing portable C++
code is significantly harder than writing "works-on-my-system" code. 
Consequently, a very large proportion of C++ code falls into the
latter category.

That isn't a problem if you're writing something for your personal use
and you're willing to abandon it once it no longer compiles on current
systems. OTOH, it is a problem for a project like GRASS, which aims to
support multiple platforms over the long term.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list