Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > g++ and VC

Reply
Thread Tools

g++ and VC

 
 
Nevyn
Guest
Posts: n/a
 
      08-16-2003
Hi, i am developing a xplatform open source project using qt,
and it did not compile out of the box on windows (VC 6.0 no SP) cos of
some C++ 'errors'

e.g.

file.h
class foo
{
..
..
..
void method(int=0);
}

file.cpp
foo::method(int a=0)
{
..
..
..
}

VC complained about re-definition of default parameter, while g++ (2.95.3)
compiled w/ even warnings (-Wall switch was on)

VC also complained for this

{
int i=0;
 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      08-17-2003

Nevyn <> wrote in message
news...
> Hi, i am developing a xplatform open source project using qt,
> and it did not compile out of the box on windows (VC 6.0 no SP) cos of
> some C++ 'errors'
>
> e.g.
>
> file.h
> class foo
> {
> .
> .
> .
> void method(int=0);
> }
>
> file.cpp
> foo::method(int a=0)
> {
> .
> .
> .
> }
>
> VC complained about re-definition of default parameter,

If you write a member function implementation outside
the class body, you should only define the default parameter
in the prototype.

> while g++ (2.95.3)
> compiled w/ even warnings (-Wall switch was on)
>
> VC also complained for this
>
> {
> int i=0;
> .
> .
> .
> for( int i=0;i<100;i++)
> .
> .
> .
> }
>


This is a well-known VC++ bug.

> again, re-definition of variable i
>
> what should i do to avoid these problems? (i am total newbie at VC)


Use a different name for one of the 'i's,
or create a 'dummy' scope:

int i = 0;
/* etc */
{
for(int i; /* etc */)
/* etc */
}

-Mike



 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      08-17-2003
John Harrison wrote:

>> what should i do to avoid these problems? (i am total newbie at VC)
>>
>> thanks a lot

>
> You'll avoid more future problems if you upgrade VC++ to the latest
> service pack.


I'd advice to do similar with gcc. 2.95.3 is over two years old and
known to have quite some issues with C++ standard compliance. You (the
OP) should update to a recent version like 3.3, or at least 3.1.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57