If you ever need to compile some codes using gcc or g++, Apple has its own package for the compiler.
You may install XCode from App Store which includes gcc
download command line package manually from Apple Developer, you need an Apple ID to access the download page.
Installation takes some minutes, then you may open terminal and type in
iMac:~ vmgamer$ gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files
iMac:~ vmgamer$ g++
i686-apple-darwin11-llvm-g++-4.2: no input files