g++ and VC

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nevyn

    g++ and VC

    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;
  • Mike Wahler

    #2
    Re: g++ and VC


    Nevyn <nevynZEROSPAM@ hotmail.com> wrote in message
    news:pan.2003.0 8.16.22.28.51.6 62060@hotmail.c om...[color=blue]
    > 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,[/color]
    If you write a member function implementation outside
    the class body, you should only define the default parameter
    in the prototype.
    [color=blue]
    > 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++)
    > .
    > .
    > .
    > }
    >[/color]

    This is a well-known VC++ bug.
    [color=blue]
    > again, re-definition of variable i
    >
    > what should i do to avoid these problems? (i am total newbie at VC)[/color]

    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



    Comment

    • Rolf Magnus

      #3
      Re: g++ and VC

      John Harrison wrote:
      [color=blue][color=green]
      >> what should i do to avoid these problems? (i am total newbie at VC)
      >>
      >> thanks a lot[/color]
      >
      > You'll avoid more future problems if you upgrade VC++ to the latest
      > service pack.[/color]

      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.

      Comment

      Working...