g++ compilation problems
- From: keith@xxxxxxxxxxxxxxxxxx
- Date: Fri, 20 Jul 2007 03:50:22 -0700
Hello, I didn't want to trouble the good people in c.l.c++, as these
are more of a compiler question than a language one.
Issue 1.
This code:
-------------------------------------
#include <vector>
typedef vector<unsigned char> bytes;
int main()
{
bytes data;
exit(0);
}
-------------------------------------
compiles fine with g++ v2.95.3, but with v3.4.3 (the most recent
version I have to hand) it fails with
xxx.cc:3: error: expected init-declarator before '<' token
xxx.cc:3: error: expected `,' or `;' before '<' token
Can someone please explain what the problem is here?
===========================================
Issue 2.
This code:
-------------------------------------
#include <iostream>
#include <string>
using namespace std;
class Base
{
public:
void f(string&) {cout << "Base::f()\n";}
};
class Derived : public Base
{
public:
using Base::f; // error here!
void f(char*) {cout << "Derived::f()\n";}
};
int main()
{
string myStr = "abc";
Derived obj;
obj.f(myStr);
}
-------------------------------------
this on is the other way round. It compiles and runs corectly using g+
+ v3.4.3, but with v2.95.3 I get:
xx.cc:15: cannot adjust access to `void Base::f(string &)' in `class
Derived'
xx.cc:14: because of local method `void Derived::f(char *)' with
same name
even though the function has a different signature.
I suspect my Issue 2 is an old compiler bug which has since been
fixed, but I don't understand what's happening in Issue 1.
Any advice welcome!
.
- Follow-Ups:
- Re: g++ compilation problems
- From: Ian Collins
- Re: g++ compilation problems
- Prev by Date: Re: Need to break a string "Hello1 Hello2 Hello3 Hello4 ..." into an array (of words) in Bash, any help
- Next by Date: Re: g++ compilation problems
- Previous by thread: Missing getmntinfo for building BSD df
- Next by thread: Re: g++ compilation problems
- Index(es):
Relevant Pages
|