# Gcc4?



## Sunnz (Aug 21, 2006)

It seems like gcc4 is the default compiler when one installs xcode...

But I am wondering, what is gcc4 like on OSX systems? Shall it be used? Would it be considered as bad practice to use 3.3?

I just came from the Linux world, and I was used to the way in Linux where 3.3 is the more stable compiler to use, and 4 is something you do when you really want something bleeding edge and you have time to deal with potential problems.


----------



## szymczyk (Aug 21, 2006)

If you want to build an Intel version of your program, you must use gcc 4. But there's still a place for gcc 3.3 if you are writing C++ programs. C++ programs compiled with gcc 4 will not run on anything earlier than Mac OS X 10.3.9. Compiling with gcc 3.3 allows you to support earlier versions of Mac OS X on PowerPC Macs.


----------



## Sunnz (Aug 21, 2006)

So I gcc3.3 doesn't build universal binaries? Or am I missing something here?


----------



## szymczyk (Aug 21, 2006)

Using gcc 4 is the easiest way to build a universal binary. But you can build a universal binary that uses gcc 4 to build the Intel version and uses gcc 3.3 to build the PowerPC version. You have to add the build setting GCC_VERSION_ppc to your project and give it the value 3.3.


----------



## Sunnz (Aug 22, 2006)

Ahh... maybe a dumb question here... but how do I actually know if something is universal binary?


----------



## szymczyk (Aug 22, 2006)

If you're running Mac OS X 10.4.3 and later, doing a Get Info on the executable file will tell you the architectures the executable was built for. The architecture information is in the More Info section.


----------



## Krevinek (Aug 22, 2006)

Sunnz said:


> I just came from the Linux world, and I was used to the way in Linux where 3.3 is the more stable compiler to use, and 4 is something you do when you really want something bleeding edge and you have time to deal with potential problems.



I remember those times... and the thing is... 3.3.3 was the devil in diguise for PPC. You would be surprised how many freakin' ICEs I would hit with code, or other very poor behavior. I went to 4.0 on Gentoo simply because 3.3 had so many issues outside of x86.

To be blunt, I don't see any reason why you would not want to use 4.0 unless you had to be compatible back to 10.3 (I mostly tinker with kernel stuff right now, and my code is Intel-focused anyways). Apple has been on 4.0 as their main compiler for a good 2 years now (including the internal usage for 10.4 seeds).


----------



## Sunnz (Aug 27, 2006)

So gcc4 is the the standard on OSX? Good!

Thanks!


----------



## Krevinek (Aug 27, 2006)

To be clear, GCC 4.x is standard for 10.3.9 or later. 3.3 was used for 10.2 and 10.3, and 2.95 was used for 10.0.

So depending on which versions of the OS you want to target with your software, you may have to use a specific version of the compiler. The good news is that XCode 2 allows you to install all 3 compilers and choose which one to use for your builds.


----------

