Skip to content

Instantly share code, notes, and snippets.

@j2doll
Last active May 29, 2018 01:58
Show Gist options
  • Save j2doll/c1a0967c7e46f684f29feb5ab5f513f7 to your computer and use it in GitHub Desktop.
Save j2doll/c1a0967c7e46f684f29feb5ab5f513f7 to your computer and use it in GitHub Desktop.
Determining 32 vs 64 bit in C++
// which32-64.cpp
// check 32/64bit for Microsoft Visual C++(Visual Studio) (or, C++ Builer, etc)
#if ((ULONG_MAX) == (UINT_MAX))
# define IS32BIT // 32bit Windows(x32)
#else
# define IS64BIT // 64bit Windows(x64)
#endif
// check 32/64bit for gcc(g++)
#if __GNUC__
#if __x86_64__ || __ppc64__
#define ENVIRONMENT64 // 64bit OS
#else
#define ENVIRONMENT32 // 32bit OS
#endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment