If you install macports you can install gcc select, and then choose your gcc version.
/opt/local/bin/port install gcc_select
To see your versions use
port select --list gcc
To select a version use
sudo port select --set gcc gcc40
The following article will describe how to configure a CentOS 5.x-based or Centos 6.x-based system to use Fedora Epel repos and third party remi package repos. These package repositories are not officially supported by CentOS, but they provide much more current versions of popular applications like PHP or MYSQL.
B. Dorow, and D. Widdows. Proceedings of the tenth conference on European chapter of the Association for Computational Linguistics - Volume 2, page 79--82. Morristown, NJ, USA, Association for Computational Linguistics, (2003)