How to compile the following source code in VC6// I have error inVC++6 but compile ok in GCC

Discussion in 'C++' started by fAnSKyer, Jun 7, 2009.

  1. fAnSKyer

    fAnSKyer Guest

    int NPart = atoi(argv[1]);
    int UsePart[NPart];

    I have error in VC++6 but compile ok in GCC
    Which compile parameter should I use?

    Thanks a lot

    Best,
    fAnSKyer
     
    fAnSKyer, Jun 7, 2009
    #1
    1. Advertising

  2. fAnSKyer

    Ian Collins Guest

    Re: How to compile the following source code in VC6// I have errorin VC++6 but compile ok in GCC

    fAnSKyer wrote:
    > int NPart = atoi(argv[1]);
    > int UsePart[NPart];


    This is gcc specific, or C.

    Use std::vector.

    > I have error in VC++6 but compile ok in GCC
    > Which compile parameter should I use?


    Do people still use VC++6?

    --
    Ian Collins
     
    Ian Collins, Jun 7, 2009
    #2
    1. Advertising

  3. Re: How to compile the following source code in VC6// I have errorin VC++6 but compile ok in GCC

    * fAnSKyer:
    > int NPart = atoi(argv[1]);
    > int UsePart[NPart];
    >
    > I have error in VC++6 but compile ok in GCC
    > Which compile parameter should I use?


    You should use e.g. std::vector, and you should not use an archaic pre-standard
    compiler like VC6.

    GCC supports C99 variadic arrays (such as your UsePart) as a language extension.

    You should use compiler options

    -std=c++98 -pedantic

    to turn that off.


    Cheers & hth.,

    - Alf

    --
    Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
    No ads, and there is some C++ stuff! :) Just going there is good. Linking
    to it is even better! Thanks in advance!
     
    Alf P. Steinbach, Jun 7, 2009
    #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. 3doutpost
    Replies:
    2
    Views:
    1,196
    Jonathan Turkanis
    Dec 3, 2004
  2. Julian
    Replies:
    12
    Views:
    806
    red floyd
    Dec 21, 2004
  3. Baget
    Replies:
    5
    Views:
    382
    Tom Widmer
    Mar 21, 2005
  4. Bruce Sam
    Replies:
    3
    Views:
    489
    Randy Howard
    Sep 30, 2004
  5. Replies:
    5
    Views:
    363
    Nathan Addy
    Sep 17, 2005
Loading...

Share This Page