g++ compilation problems
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > g++ compilation problems




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    g++ compilation problems  
keith@bytebrothers.co.uk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-20-07 12:20 PM


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!






[ Post a follow-up to this message ]



    Re: g++ compilation problems  
Ian Collins


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-20-07 12:20 PM

keith@bytebrothers.co.uk wrote:
> 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;

typedef std::vector<unsigned char> bytes;

Old gcc was very slack in its use of std::
>
> 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!
>
Don't use old compilers!

--
Ian Collins.





[ Post a follow-up to this message ]



    Re: g++ compilation problems  
keith@bytebrothers.co.uk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-20-07 12:20 PM

On 20 Jul, 12:00, Ian Collins <ian-n...@hotmail.com> wrote:
> ke...@bytebrothers.co.uk wrote:
> 
>
> typedef std::vector<unsigned char> bytes;
>
> Old gcc was very slack in its use of std::

Bingo.  Thank you, thank you!

(as you can probably tell, I'm slowly making the 'paradigm shift' to C+
+ after 20 years of C, and stuff like that floors me every time)






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:45 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register