gcc and namespaces

gcc and namespaces

Post by Donn Mille » Wed, 05 Jan 2000 04:00:00




> Hello
> I was wondering if someone could shed some light on this one. I'm trying
> to port an app to FreeBSd which uses gmake and gcc. The result is this
> error:

> ../../include/swconfig.h:32: warning: namespaces are mostly broken in
> this version of g++

So, which version of gcc was it?  What's the output of gcc -v?

- Donn

 
 
 

gcc and namespaces

Post by Stuart J Campbel » Thu, 06 Jan 2000 04:00:00


Hello
I was wondering if someone could shed some light on this one. I'm trying
to port an app to FreeBSd which uses gmake and gcc. The result is this
error:

../../include/swconfig.h:32: warning: namespaces are mostly broken in
this version of g++
../../include/swconfig.h:35: parse error before `<'
../../include/swconfig.h:36: `ConfigEntMap' was not declared in this
scope
../../include/swconfig.h:36: type/value mismatch in template parameter
list for `template <class Key, class T, class Compare> class map'
../../include/swconfig.h:36: warning: ANSI C++ forbids typedef which
does not specify a type

Am I looking at needing another version of gcc, a rewrite, what?

 
 
 

1. gcc 2.96 vs. gcc 3.2: namespace, template incompatability

The old code I once wrote in redhat 7.3(gcc 2.96) are no longer
compiled without errors in gcc 3.2 after I upgrade to redhat 8.0.

In gcc 3.2, the compiler always complain that 'cin', 'endl' etc. are
undefined unless I add the line "using namespace std".

In addition, there is also some problem in template, for example, the
code segment below is compiled OK in gcc 2.96, but there are a lot of
errors given by gcc 3.2. And there is still a error after I add "using
namespace std"

$ g++ -o max_string max_string.C
max_string.C: In function `int main()':
max_string.C:37: cannot convert
`__gnu_cxx::__normal_iterator<std::string*,
   std::vector<std::string, std::allocator<std::string> > >' to
`std::string*'
   in initialization
$

// code segment in "C++ Primer" chapter 20 iostream library
#include <string>
#include <algorithm>
#include <iterator>
#include <vector>
#include <iostream>

using namespace std;

bool length_less( string s1, string s2 )
    { return s1.size() < s2.size(); }

template <class InputIterator>
void filter_string( InputIterator first, InputIterator last,
                    string filt_elems = string( "\",?." ))
{
    for (; first != last; first++) {
        string::size_type pos = 0;
        while ( (pos = (*first).find_first_of(filt_elems, pos))
                != string::npos )
            (*first).erase( pos, 1 );
    }

int main()
{
    istream_iterator<string> input( cin ), eos;

    vector<string> text;
    // copy is a generic algorithm
    // copy from standard input to text
    copy( input, eos, back_inserter( text ));
    string filt_elems( "\",.?;:" );
    filter_string( text.begin(), text.end(), filt_elems );

    int cnt = text.size();
    // max_element is a generic algorithm
    string *max = max_element( text.begin(), text.end(), length_less
);
    int len = max->size();

    cout << "The number of words read is " << cnt << endl;
    cout << "The longest word has a length of " << len << endl;
    cout << "The longest word is " << *max << endl;

2. Problems w/STB Wind/X (S3/911) card (XF3.1.1)

3. GCC and namespaces, bool, stl, exceptions, etc ...

4. MySQL error

5. Namespace issue with GCC 3.2 - questions

6. PPP Setup problems and general problem in fvwm

7. Matrox Mystique ands X.

8. GoTo button

9. File Namespace Socket Question

10. NIS+ loop in namespace error

11. Xlib.a Q: Window ID namespace & MULTIPLE Displays?

12. VFS: namespaces and mount

13. fix oops in namespace.c