xcode compilers and C++

Discussion in 'Mac Programming' started by Kwokho, Aug 20, 2008.

  1. Kwokho macrumors newbie

    Joined:
    Aug 20, 2008
    #1
    Is carbon c++ ansi? And is there any other compilers other than xcode which is ansi?
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Carbon is an API. The ANSI standard relates to the language and makes no mention of APIs. In fact Carbon is actually a C API not C++. Xcode is an IDE not a compiler. The compiler that Xcode uses is GCC.

    There is also the Intel C/C++ compiler for Mac OS X but that is not free.
     
  3. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    I doubt very seriously that there is a C++ compiler that is ANSI compliant. How many support export? That's at least well known, who knows what else is in the standard that few if any compilers support.

    What are you trying to achieve? Do you have some code that won't compile with the compiler you have, but you believe it to be standards compliant?

    Also, Xcode is not a compiler, it is an IDE that utilizes gcc/g++/java for compiling various languages. You can use g++ from the command line and get the same results as with Xcode.

    Perhaps you should define your problem more clearly and we'll be able to give you some better direction.

    -Lee
     
  4. Kwokho thread starter macrumors newbie

    Joined:
    Aug 20, 2008
    #4
    did you started programming with HELLO WORLD thing? If so where should I write it in xcode is it the source?
     
  5. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #5
    What resource are you learning to program with?

    From the sounds of it I would skip Xcode at the moment and just work with a text editor and the command line. It will be much easier to learn to start out with, worry about Xcode later.

    All you need to do is get a decent text editor (I recommend Smultron) and type your code in there. Save the file calling it anything you want but make sure to add a .c extension to it. Then open Terminal in /Applications/Utilities and navigate to the folder where you saved it (if you saved it to the Desktop you would type cd Desktop).

    Once that is done type:

    gcc -o myprog whateveryoucalledyourfile.c

    and your code will be compiled and given the name myprog, obviously you will need to change the filename to whatever you called your file and you can change myprog to anything you like. To run your program type:

    ./myprog
     
  6. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    Slight modifications for C++:
    Save your file as .cpp, .C, .CPP, .cc, .cp, .cxx, .c++. The first is the most common.
    Instead of gcc, run g++:
    g++ -o myprog whateveryoucalledyourfile

    -Lee
     
  7. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #7
    Oops, yes sorry about that. Forgot we were talking about C++.
     
  8. Kwokho thread starter macrumors newbie

    Joined:
    Aug 20, 2008
    #8
    how do I make it to a app?
    like you can click on it in the dock?
     
  9. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    That'll come later. Concentrate on learning the language first, making GUI applications is something you can worry about in a few months when you have got the basics under your belt. 99% of the stuff you do when learning will be command line based with a programming language like C++.
     

Share This Page