Reputation: 75
Hello could anyone give me an example showing how do we use conditional compilation for different versions of operating system? for example I want a program that works depending on the version win32 or win64 or on other platform
Upvotes: 0
Views: 253
Reputation: 25083
I think what you want is explained here on MSDN. Basically, you #define WINVER
to indicate the target operating system.
This is the relevant part of that page:
Setting WINVER or _WIN32_WINNT
You can define these symbols by using the #define statement in each source file, or by specifying the /D compiler option supported by Visual C++.
For example, to set
WINVER
in your source file, use the following statement:#define WINVER 0x0502
To set _WIN32_WINNT in your source file, use the following statement:
#define _WIN32_WINNT 0x0502
To set _WIN32_WINNT using the /D compiler option, use the following command:
cl -c /D_WIN32_WINNT=0x0502 source.cpp
For information on using the /D compiler option, see /D (preprocessor definitions).
Upvotes: 2