-1

and also a 32bit OS from a 64bit OS? Are there some #ifdef I can use to detect the actual OS version and whether it is 32 or 64 bit?

shawn
  • 4,063
  • 7
  • 37
  • 54
  • What toolchain/compiler are you using? I wouldn't use an `#ifdef` to detect XP vs. Windows 7, but you might have to for 32-bit vs. 64-bit. But there are probably better ways than an `#ifdef` to make your code 64-bit clean and portable... – mpontillo Feb 26 '12 at 05:55
  • 1
    Take a look at [Detect whether current Windows version is 32 bit or 64 bit](http://stackoverflow.com/questions/601089/detect-whether-current-windows-version-is-32-bit-or-64-bit) and [How can I detect the operating system in C/C++?](http://stackoverflow.com/questions/430424/how-can-i-detect-the-operating-system-in-c-c) – Parag Bafna Feb 26 '12 at 05:56
  • You want to determine at compile time? – stark Feb 26 '12 at 05:58

1 Answers1

5

At compile time you can use the WINVER & _WIN64 macro's, though this info is for the OS(es) being targeted, not the OS being compiled on.

At runtime you can use GetVersionEx to get OS version info and IsWOW64Process to determine if you are running on 64 or 32 bit.

Necrolis
  • 25,836
  • 3
  • 63
  • 101