0

I'm trying to compile a simple C program on mac However I can't ever seem to get Xcode to work so I want something else. I also want to check the code for errors while I'm running it anyone got a good idea?

Thijser
  • 2,625
  • 1
  • 36
  • 71
  • 2
    XCode comes with the `gcc` and `gdb` command line tools which work (mostly) just like their Linux equivalents. Xcode is just a graphical front-end for those tools. – Sergey L. Mar 21 '13 at 13:30

1 Answers1

5

open Terminal, cd to your source directory,

then type gcc -Wall yourProgram.c -o YourProgram and if everything is good, you will be able to execute the program typing ./YourProgram

Also, if you are just learning C, then do not use IDEs just yet. get used to the terminal and as your experience builds, move to an IDE.]

Also there are tools like lint that analyze your code statically. Use gdb and if available, use valgrind as well for runtime debugging. I am not sure if valgrind is available on mac. Have a look at dtrace and how to use it.

Aniket Inge
  • 25,375
  • 5
  • 50
  • 78