g++ 3.2 questions

llewelly@xmission.com llewelly@xmission.com
Thu Apr 8 15:39:00 GMT 2004


Greg Hosler <greg@hosler.per.sg> writes:

> Hi All,
> 
> I've got a large C++ application that compiles/runs just fine on RH7.3 - I'm in
> the process of porting it to RHEL3, and I am having some C++ issues.
> 
> My program has some usage of iostreams / fstream / etc C++
> constructs.

Please see http://gcc.gnu.org/bugs.html#upgrading and search for 'New in GCC 3.0' .

Try placing the using directive 'using namespace std;' after the last
    #inclusion of a standard header. That should fix most of your
    probelms. The redhat gcc 2.96 you most likely used on RH7.3 will
    accept the using directive, but does not require it, as it treats
    std as an alias for the global namespace. The 1998 ISO C++
    standard requires that standard library names be confined to the
    std namespace, and so does gcc 3+ .

In the meantime, I suggest you pick up a good book on ISO C++, such as
    Bjarne Stroustrup's _The C++ Programming Language_ 3 edition or
    special edition (they are nearly the same).

> Some of the questions I have are:
> 
>         - I noticed that there are 2 sets of C++ header files.
>           one is "compat-libstdc++-devel-7.3-2.96.123", and the
>           other is "libstdc++-devel-3.2.3-24"

I am guessing, but I bet the compat-libstdc++-devel-7.3-2.96.123
    headers are intended only for use with g++2.96, which you may have
    to install seperately.

Note that compat-libstdc++-devel-7.3-2.96.123 and libstdc++-devel-3.2.3-24
    are artifacts of redhat's packaging decisions, have nothing to
    do with fsf gcc proper, and are somewhat obscure to those of us
    who use redhat only infrequently.

fsf gcc 3.2 comes only with the libstdc++-v3 headers, and no
    2.96-specific compat headers.

> 
>           Is there any rule of thumb as to which set of header files I should
>           use ?

You should use the compat-libstdc++-devel-7.3-2.96.123 headers
    only with gcc 2.96, and the libstdc++-devel-3.2.3-24 headers only
    with gcc 3.2

Each set of headers will have a matching set of libraries that go with
    it. Each compiler will have an accompanying set of headers and
    libraries that go with it.

> 
>         - It seems that by default, libstdc++-devel-3.2.3-24 is being used.
> 
>           As I have a lot of pre ISO C99 constructs,

Surely you mean pre- ISO C++ 1998 ? g++ 3.2 does include several
    extensions derived from C99, which are enabled by default, but
    they seldom cause compilation problems for C++ (or C) code. If
    they are a problem, -ansi is one way to turn them off.

>           this set of header files
>           seems to be giving me fits. If I use -I /usr/lib/g++-3, most of my
>           compilation errors go away (but leave me w/ link errors).

The linker errors are insoluble, without some exceedingly smart linker
    magic, which no-one has written.

>           Question
>           is there a non-default c++ library that I need to specify
>           ?

You must use the C++ headers and libraries that match the C++ compiler.

> 
>         - What are the implications, limitations, issues, with linking together
>           object files created with -I /usr/lib/g++-3, and without (i.e. with
>           "standard" g++ header files. i.e. should this work ? Is this known to
>           not work ? etc.

It is known not to work.

> any thoughts, or tips (or pointers) would be much appreciated.
> 
> (is there any documentation on these I could have read ? I looked around, and
> at various web sites, but was unable to find anything. :(  )

In addition to the link about upgradiing to gcc 3.0, and TC++PL3, you
    could have read any good book on modern C++, such as those written
    by Stroustrup, Koenig, Austern, Lippman, Josuttis, Vandervoode,
    etc. 



More information about the Gcc mailing list