[GRASS5] C++ stuff (r.terraflow) doesn't compile on gcc-3.3

John Gillette JGillette at rfmd.com
Fri Oct 17 10:45:41 EDT 2003


I don't know C++ so I may not be correct but in
doing some research on the problem here is what I
learned.

This is a known problem in the programming world
caused by the fact that gcc 3.2 and previous is not 
compliant to the current c++ standard. Starting
about 3.3 programs starting "breaking" and there are
lots of questions on the web about programs which
stopped compiling.

The problem is related to namespaces and the headers.
Included below is an exchange I found explaining why the
famous "Hello World" program will not compile as before.

I hopes this helps in understanding what's wrong with
r.terraflow.  Unfortunately, I don't know what the solution
is.

John



----------------------------
Ronald Petty ron.petty @ unigeek.com 

Hi,
It has been awhile since I have done c++ programming using gnu g++/gcc
and I have a question (yes I googled it).


#include <iostream.h>

int main()
{
        cout << "Hello world\n";
        return 1;
}

g++ jab.cc
In file included from /usr/include/c++/3.2/backward/iostream.h:31,
                 from jab.cc:1:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning
This file includes at least one deprecated or antiquated header. Please
consider using one of the 32 headers found in section 17.4.1.2 of the
C++ standard. Examples include substituting the <X> header for the <X.h>
header for C++ includes, or <sstream> instead of the deprecated header
<strstream.h>. To disable this warning use -Wno-deprecated.


I looked for something called "C++ standard" but can't find it.  I also
looked for 17.4.1.2 and nothing.  Basically is there a list of the
headers and api documented somewhere?  I am using 

gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=i386-redhat-linux --with-system-zlib
--enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

------------------------------------------------------------------------


ext tor torsionfreemodule @ yahoo.com 

Hi Ron,
Your program should look like:
#include <iostream>
int main()
{
    std::cout << "Hello World\n";
    return 1;
}

Two things to note here are that the C++ standard
libraries make use of namespaces, and that the header
should be <iostream>.  17.4.1.2 basically just gives a
list of the 32 standard headers, of which <iostream>
is one.  There is a pretty nice reference to the
standard C++ libraries at
http://www.dinkumware.com/refxcpp.html.  All of this
is also documented in Stroustrup's _The C++
Programming Language_.  The iostream.h headers are not
compliant with the standard because they do not use
namespace std.  Hence their deprecation.

------------------------------------------------------------------------
Jirsa, Jeff Jeff.Jirsa @ tfn.com 

To avoid having to type the namespace all of the time, try:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello World\n";
    return 1;
}

I like this better -- I don't have to put "std::" in all of 
my cin and cout statements.

-----------------------------------------------------------------------
Jirsa, Jeff Jeff.Jirsa @t tfn.com 

The template based headers. They don't have a ".h" extension.
iostream.h is pre-STL, I believe.




More information about the grass-dev mailing list