g++ and VC

Discussion in 'C++' started by Nevyn, Aug 16, 2003.

  1. Nevyn

    Nevyn Guest

    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;
    Nevyn, Aug 16, 2003
    #1
    1. Advertising

  2. Nevyn

    Mike Wahler Guest

    Nevyn <> wrote in message
    news:p...
    > 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
    Mike Wahler, Aug 17, 2003
    #2
    1. Advertising

  3. Nevyn

    Rolf Magnus Guest

    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.
    Rolf Magnus, Aug 17, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nut Cracker
    Replies:
    1
    Views:
    338
  2. jakk
    Replies:
    4
    Views:
    12,112
  3. Tim Meagher
    Replies:
    8
    Views:
    1,288
    Karl Seguin
    Jun 18, 2005
  4. Jerry Manner
    Replies:
    2
    Views:
    6,538
    SpaceGirl
    May 30, 2005
  5. titi

    if and and vs if and,and

    titi, Mar 9, 2007, in forum: VHDL
    Replies:
    4
    Views:
    578
    Mike Treseler
    Mar 11, 2007
Loading...

Share This Page