question about c++ in xcode

Discussion in 'Mac Programming' started by xxcysxx, Dec 29, 2012.

  1. macrumors 6502

    Joined:
    Oct 12, 2011
    #1
    hello folks,

    in visual studio i can just use

    using namespace std;
    int main()
    {
    return 0;
    }

    and in xcode i have to use

    using namespace std;
    int main(int argc, const char * argv[])
    {

    return 0;
    }

    for it to work? how come i cant do the main without any argument in the parenthesis like i did in visual studio?
    i tried to do it and get compile failed.

    i did use google to search but i only understand what the argument does, but i still don't understand why xcode requires it where as visual studio doesn't.

    thanks for any inputs folks
     
  2. thread starter macrumors 6502

    Joined:
    Oct 12, 2011
  3. macrumors 6502

    Joined:
    May 20, 2008
    Location:
    London, United Kingdom
    #3
    What some compilers allow you to get away with is quite shocking!
     
  4. macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    I generally write my C code in gEdit and then compile it by using make in Terminal... I'm pretty sure it'll compile without any arguments in main() just fine.
     
  5. macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #5
    ? I never had to use them in Xcode. You *should* use them because its considered proper practice but most programming books omit them for some reason.
     
  6. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #6
    Most of the time when C++ code compiles on Windows and doesn't compile with either gcc or clang, it turns out that the code was illegal in the first place but some windows compiler still accepted it.
     

Share This Page