I am building my solution for x86 and x64 platforms. Does Visual Studio have any target platform variables so I find which platform I am building for in compile time?
For example:
HINSTANCE hinstLib;
#ifdef TARGET_X86
hinstLib = LoadLibrary("32lib.dll");
#endif
#ifdef TARGET_X64
hinstLib = LoadLibrary("64lib.dll");
#endif
This is what I use:
#if defined(_MSC_VER)
// Microsoft VC compiler
# if defined(_WIN32)
# if defined(_WIN64)
// 64 bit windows
# else
// 32 bit windows
# endif
# endif
#endif
Note that _WIN32 is defined for 64 bit too.
Have a look here: http://msdn.microsoft.com/en-US/library/b0084kay.aspx
_WIN64
or _M_X64
should work.
So for your example:
HINSTANCE hinstLib;
#ifdef _WIN64
hinstLib = LoadLibrary("64lib.dll");
#else
hinstLib = LoadLibrary("32lib.dll");
#endif
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.