Well, the answer will obviously be OS specific, so you need to narrow down your requirements.
For example, on Unix uname -a usually enough information is provided to distinguish between a 32-bit OS build and a 64-bit build.
The command may be called by your precompiler. Depending on its output, compiler flags may be set accordingly.
source share