By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,232 Members | 1,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,232 IT Pros & Developers. It's quick & easy.

g++ and VC

P: n/a
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;
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Nevyn <ne***********@hotmail.com> wrote in message
news:pa****************************@hotmail.com...
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

Jul 19 '05 #2

P: n/a
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.

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.