You can use conditional defines to detect most OS'es, like described here:
........
Detecting if you program is 32bit or 64bit can be done with:
.......
Which is not what he asked.
1. You can not use only ifdefs at runtime. The example detects where the code is compiled for. Doesn't answer the question.
2. You can not detect the bitness of the OS based on pointer size (e.g. a win32 application will happily run on win64 and happily return a 32 bit pointer....). Doesn't answer the question.
3. It is definitely possible to detect OS, Version, Endianness and bitness at runtime (partially using ifdefs, but with syscalls to determine the true identity... Regardless of the subsystem the program is compiled for.
What he DOES ask is a generic, cross-platform set of routines that return OS, bitness and version at runtime.
That's the reason I used ppcjvm code: Java contains such a set of routines.
There is some code that is semi-crossplatform: just linux and windows and 32 and 64 bit.