Question about XCode and C

Discussion in 'Mac Programming' started by the87boy, Sep 12, 2007.

  1. the87boy macrumors newbie

    Joined:
    Sep 11, 2007
    #1
    On my university we are starting to have C-programmering, but I can't set up X-code on my MAC, so I can start programmering. The reason why I can't set up X-code is, that I don't know which project-type, I should choose, because there are no project just about C
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You need to select something like Command line foundation tool (sorry don't have XCode installed on this Mac right now to give the exact name...)
     
  3. mashkina macrumors member

    Joined:
    Nov 4, 2006
    Location:
    Dubai
    #3
    The XCode comes in the installation disk(s) of your Mac. You don't need to install MacOS again. There is a file there with the name "Xcode installation". I don't know if that is your problem. On the other hand ANSI-C is compatible with the Mac C. The differences are just in some definitions, such as "float32" instead of "float", for instance. If U want to program in Object C (C++) I cannot help you much with that.
     
  4. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #4
    For plain C programs, use "Standard Tool". For plain C++ programs, use "C++ Tool".
     
  5. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #5
    First things first.

    You should not be using XCode to learn C programming with. It is like using a sledge hammer to crack a wallnut. Complete overkill.

    Secondly XCode will hide too many details. Unless you use the gcc tools from the command line, you will never understand the difference between compiling and linking code. You will think everything works when you press the hammer tool.
     
  6. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #6
    Why overkill? If he's learning C, he should be concentrating on learning C, and everything else is just obstacles. No point in learning to use the linker if that means falling behind in your C course and having trouble catching up. Using XCode is not like using a sledge hammer to crack a walnut, which is a very bad method because it doesn't leave you with anything edible - it is like using a sophisticated automated walnut cracker to crack walnuts.

    I'd much rather that someone learns using XCode properly, how to use different build targets, how to generated x86 vs. PowerPC or 32 bit vs. 64 bit code, how to build a bundled application, add icons, add help files, plist files and so on than learning how to use a linker.
     
  7. Soulstorm macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #7
    Using Xcode is not overkill. Actually, it is really efficient for beginners, as an IDE automates all unnecessary (for a beginner) steps and lets the beginner concentrate on the development process and not on the compilation process. After he/she has learnt the IDE, he/she may use the command line tool. Otherwise, it's not recommended.
     
  8. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #8
    Oh dear.

    Oh dear, oh dear.

    C is a low level language. How are you going to work on an embedded environment if you don't know how to use the compiler or linker.

    No don't answer that, based on your previous answers I would fall off my seat laughing.

    Yes XCode is like cracking a wallnut with a sledgehammer. It doesn't take any command line switches to compile simple C programs. What happens if this guy gets a job with a software company that develops software in C that runs on a server with a textbased Ptty interface?

    I will say it again. Oh dear. I just hope I never have to interview the two of you. I would probably have to leave the interview room to stop myself laughing.
     
  9. lazydog macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #9
    Actually for some people I think X-code is a good place to start . Not everyone wants or needs to know about compiler and linker switches/options right from the word go. Choosing X-code as your first exposure to programming doesn't preclude learning the command line way in the future.
    Anyway, the project preferences in X-code present an easy interface to playing around and reading up on the various switches. I honestly think this 'you have to learn from the bottom up' attitude is a bit over rated though. I mean where does it end? Surely you should be learning assembler before learning C? Or how about construct your own Turing machine out of ping-pong balls, buckets and springs :) Just my opinion… so don't jump on me!!!

    b e n
     
  10. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #10
    I won't jump on anyone, but I can pretty much guarantee that most of the assignments for a first class in C will be command based using a few files at most. They should be teaching this on Unix boxes or Linux boxes. Not because this is an elite way of doing it, but rather it is the home of C.

    Also from a simple point of view, you have to unless the OP has a really rubbish university, hand in all source code and it has to be written to be easily compilable. Writing your programs in XCode and then trying to work out how to write a Makefile is going to end in a failure.

    I still remember laughing when I read in Joel On Software that most universities in the US don't teach C anymore. It is too difficult so they teach Java, and then not even standard Sun Java, they give them wrapper classes that box and unbox integers automatically, so the students have no idea what the difference between and int and Integer is.
     
  11. lazydog macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #11
    I think you make some very good points, Still, I think that there is no single right way or path to learn programming. Learning compiler flags and makefiles before learning how to do a for loop is one way to start, but perhaps not suited to everbody, and I'm not entirely convinced that there is any long lasting intrinisic benefit from doing it that way anyway. In the end does it really matter what came first, the makefile or the IDE?

    b e n
     
  12. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #12
    At my university, the first C class was originally taught on Windows XP using PuTTY to access Linux machines, in turn using gcc and vi. I don't remember people having too much trouble with that setup, I just remember them having problems with the syntax of C. But now, a few years after I originally took the course, they have switched it all over to VS, which is a pity since I do believe you should be familiar with the command line before moving to an IDE.
     
  13. thealtered7 macrumors newbie

    Joined:
    Sep 11, 2007
    Location:
    Denver
    #13
    You can't play Jazz until you learn your scales...
     
  14. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #14
    Feel free to fall off your seat.

    The guy is doing a C course. He isn't doing a course in writing software for embedded environments. When you learn driving, you don't start by learning to change the oil in your car. You get into the car and learn holding on to the steering wheel and moving the car in a straight line, stopping when necessary. A bit later you learn how to drive a curve. Way, way later you may learn how to change the oil, but some people never bother learning it and can still drive very well. Learning how to get someone else to change the oil for you is a very good technique, works for most drivers.
     
  15. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #15
    So do you have any idea how to integrate a few perl scripts into the XCode build process? Any idea what belongs into a plist file? How to process a reply to an AppleEvent? How to write 64 bit clean C code?

    Should I ever have to start a C compiler on an embedded system, I'll just take the manual. Should I ever have to compile stuff on a server using ptty, I'll switch to archaeology and start digging for dinosaur bones. Learning to know everything is a very inefficient use of my time. Knowing who to ask, and knowing how to make them do it, is ten times more efficient.
     
  16. MacDonaldsd macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #16
    I would do it in terminal to be honest with you. My first year we done everything on Windows in Visual studio, and now we just use linux.

    I found it pain setting up the reading and writing to files as it was in a different manner using Visual Studio. You want to pass your course first and foremost.
     
  17. the87boy thread starter macrumors newbie

    Joined:
    Sep 11, 2007
    #17
    What will you then recommend just to highlight C-code (syntax highlighting)?
    It's the only thing, I'm missing except from gcc, but isn't it already installed?
     
  18. philippott macrumors newbie

    Joined:
    Sep 17, 2007
    #18
    Regarding your C classes I think you wont need any sophisticated library or frameworks at the beginning.

    The easyiest way is still:

    1) install xcode (with defaults). Xcode is available for download from Apple and it usually also ships on their install DVD - the late 2006 imac I have here has it on the DVD - cant remember if #1 or #2 though.

    2) make a folder in your home directory, use Terminal.app to go there

    3) launch XCode, click New Empty File

    4) enter something like

    #include <stdio.h>

    int main(int argc, char *argv[])
    {
    printf("Hello World\n");
    return 0;
    }

    5) save it as test0001.c into this new folder - and voila, syntax highlighting will be turned on

    6) in the Terminal window you can compile test0001.c with

    gcc -Wall test0001.c -o test0001

    and run it with

    ./test0001

    You dont need to buy or download any other software (syntax highlighting supporting text editor etc) and this way you can stick closely to a basic C class.

    Regards
     
  19. the87boy thread starter macrumors newbie

    Joined:
    Sep 11, 2007
  20. MacDonaldsd macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #20
    I think it installs when you install Xcode.
     
  21. lazydog macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #21
    Learning to use the command line to compile and link isn't a big deal, and once you know how to do it I can't really see any point for not moving over to X-code. An advantage of using X-code is that you will be able to debug your program using X-codes front end to the debugger. Stepping through your code is a good way to understand how your program works, and why it doesn't work, and X-code's debugger makes this a breeze.

    b e n
     
  22. jimbohampton macrumors newbie

    Joined:
    Sep 14, 2007
    #22
    another problem besides xcode

    Did anyone else notice that he uses the spelling "programmering"... TWICE. I think he has more basic problems than figuring out how to use xcode.
     
  23. mward333 macrumors 6502a

    mward333

    Joined:
    Jan 24, 2004
    #23
    Wow, give this guy a break. Two or three of the posts above are so abrasive! We should be a friendly, inviting community.

    To the OP-- Good luck starting to learn the C language. It is a fun and challenging process. Everybody on this forum went through the process, and you are invited to the party! I write C++ nearly every day for my research, and I really enjoy this practical side of my job. (I'm a university professor.)

    So stick with it, and let us know when you have trouble. We're here to help.

    Please forgive the folks who are not-too-understanding. Don't worry about it.
     
  24. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #24
    But did you know that XCode has a built-in spelling checker? :D
     
  25. fimac macrumors member

    Joined:
    Jan 18, 2006
    Location:
    Finland
    #25
    This is good advice.

    This thread reminds me of the beginning of K&R where IIRC the authors say that the hardest step is simply to get something to compile, link and run. After that everything gets easier ;)
     

Share This Page