Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

andrewface

macrumors 6502
Original poster
May 17, 2006
284
56
whats a good c compiler for mac? i need it for my course...any suggestions

xcode do the trick?
 

Kodex

macrumors member
Jan 30, 2003
75
0
Xcode has your back it is a fully functional and free C complier. If you are feeling a bit confident you can also use the terminal and gcc
 

andrewface

macrumors 6502
Original poster
May 17, 2006
284
56
Xcode has your back it is a fully functional and free C complier. If you are feeling a bit confident you can also use the terminal and gcc

cool where can i get xcode? or how do i install it i guess?
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0
whats a good c compiler for mac? i need it for my course...any suggestions

xcode do the trick?

before you turn in you homework you should compile and test it on whatever specification your prof sets out. if you projects get large enough, you end of losing dev to time to fixing the difference between compile rather than completing you project. for a newbie might be best to start on the system the your case is setup.
 

hopejr

macrumors 6502
Nov 10, 2005
310
0
New South Wales, Australia
Yeah, that should be fine for whatever you need for your course, as long as you keep in mind that not all gcc commands are supported in OS X, but you probably won't have any problems with that. I just use it with terminal instead of Xcode.
I agree, unless you need to write a cocoa or carbon app. If you need help on commands, just use the manual pages in the Terminal (man).

BTW, XCode isn't a compiler, it's an Integrated Development Environment. It uses GCC as the compiler as was stated earlier.

To use GCC in the terminal, just type:
gcc <c file name> -o <executable file name>
just like you would on any *n?x.

If you need to use make at all, that works too. So does gdb (XCode uses that for debugging).
 

andrewface

macrumors 6502
Original poster
May 17, 2006
284
56
my prof was talking about how C is universal and can work with many operating systems...can i write windows programs in xcode? i think ill most likely have to hand in windows apps (uhg ****ing windows)...
 

pilotError

macrumors 68020
Apr 12, 2006
2,237
4
Long Island
As long as your not creating visual elements (windows, dialog boxes, etc.) c-code is pretty generic and portable.

Talk to the professor and tell him your situation. I don't think they would force you to buy a windows PC just to compile.

He may want to run code on his own PC just to check though...

Mike...
 

Swarmlord

macrumors 6502a
Sep 18, 2006
535
0
As long as your not creating visual elements (windows, dialog boxes, etc.) c-code is pretty generic and portable.

Talk to the professor and tell him your situation. I don't think they would force you to buy a windows PC just to compile.

He may want to run code on his own PC just to check though...

Mike...

In fact a Windows PC should be the platform of last resort for a class on C. If I wasn't programming on my Mac, I'd be coding on somee flavor of Linux (and still be using gcc.) You could purchase a new Mac for what Microsoft will gouge you for some variety of .NET.
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0
my prof was talking about how C is universal and can work with many operating systems...can i write windows programs in xcode? i think ill most likely have to hand in windows apps (uhg ****ing windows)...


lol!

even simple programs that use simple file i/o between windows/dos and *nix which includes os x cause problems.

you are going to be doing a lot of #ifdef if you are writing coding on multiple platforms. i maintained code for about a year that was 10 years old. The first ver was written for a sun sparc then pushed over to bsd then windows then linux then a mac. yeah a lot of the code was the same but there are alot #ifdef to make code specific to PPC or x86 for example.

a good example if you try to use a library to print an IP address from x86 linux and get the code to compile on a PPC running OS X the ip address will print backwards due the little endian on a PPC.
 

andrewface

macrumors 6502
Original poster
May 17, 2006
284
56
so if all i need is a c compiler should i bother installing the whole xcode package or should i just install gcc 4.0?

i dont need the whole 2.4 gigs installed i wont use any of it?
 

andrewface

macrumors 6502
Original poster
May 17, 2006
284
56
ok i installed the whole developers tools thing...when i first ran xcode it said new user...i exited the program...now it doesnt ask to set up new user...how do i set up a new user now?
 

bousozoku

Moderator emeritus
Jun 25, 2002
16,120
2,397
Lard
If I recall from running Xcode the first time, it asks a bit about how you want the main window and the project window set and where you want to put binaries and things like that. It's not a big deal.

You should at least try the Xcode editor, even if you're going to compile on the command line. It saves me from starting emacs.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
a good example if you try to use a library to print an IP address from x86 linux and get the code to compile on a PPC running OS X the ip address will print backwards due the little endian on a PPC.

Only if the original programmer didn't know their stuff. Lookup "htonl" and "ntohl".
 

pilotError

macrumors 68020
Apr 12, 2006
2,237
4
Long Island
Only if the original programmer didn't know their stuff. Lookup "htonl" and "ntohl".

LOL...

Was thinking the same thing but wouldn't say it.

We still push around 15+ year old c-code between platforms. Some of the stuff originated on VMS then to HP/UX or Sun and now to Linux. I love doing porting work. Getting old code that used to take an hour to do a task and having it run in like 4 minutes gives you a sense of accomplishment!
 

colocolo

macrumors 6502
Jan 17, 2002
480
132
Santiago, Chile
Andrew,

I dont think an intro course to C will require you to do Windows or any GUI-specific app.
Of course, I'm assuming its an introduction to programming in general and not just C, so probably you'll get only as far as using the stdin and stdout as your input/output.

If that's the case, you can write the programs in any environment you wish and it will work seamlessly.

BTW, did anyone else have to do their first programming course in college using scheme? :p
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.