g++ and VC

N

Nevyn

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;
 
M

Mike Wahler

Nevyn said:
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
 
R

Rolf Magnus

John said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top