Code::Blocks is a very generic IDE that can use many compilers. You can even have different compilers for every project.
Depending on what version you have installed (I have the Nov 11 2009 build, running under Windows) when you have a project loaded you can go to the "Project menu" -> "Build options" item and you will see what compiler you are using for that project - keep a note of it. Close that window and then go to the "Settings" menu -> "Compiler and debugger..." item. In the window it brings up make sure you have the "Global compiler settings" icon selected from the list on the left. Change to the "Toolchain executables" page from which you can get the exact path to the compiler executable that your project is using by making sure the "Selected compiler" drop down box at the top of the screen matches the one for your project".
The other way to get that information is to build your project, then switch to the "Build log". The command line should at least have the compiler executable as part of the filename it shows.
From the compiler filename you can then detemine whether it is some sort of GCC derivative or something else (such as MSVC). At this point it becomes compiler specific to find out what version you are using. For example, if it is GCC or a port then you can run:
<path and filename of compiler> --version
from a command prompt/shell to get the version number.
If it is MSVC, then simply running:
<path and filename of compiler>
will display the version number.
If you want to do it from your compiler (although technically it will be the preprocessor) you will need to know the above information to know what your compiler is, as you need to know the preprocessor macros to check for, which are compiler dependant.
On the plus side, Code::Blocks is likely to use GCC unless you have specifically downloaded the version without MinGW on Windows. So you are probably OK to use the method Ben Voigt describes.
Edit: missing line breaks hid the compiler version command lines