Targeting Stubs for Specific 32-bit or 64-bit Platforms
Some of the features of Microsoft RPC and the MIDL 3.0 and later compilers are platform-specific.
As a precaution, the MIDL 3.0 and later compilers generate guards that facilitate compatibility checking during the C-compilation phase. MIDL generates two types of guards: a platform-dependent guard (32-bit versus 64-bit) and a release-dependent guard (feature set dependency). For example, MIDL generates the following guard to prevent C-compiling of a 32-bit stub for other platforms:
#if !defined(__RPC_WIN32__) #error Invalid build platform for this stub. #endif
The release-dependent guard is triggered by a set of features found in the processed IDL file(s) and by the /target switch. For example, if the interface uses features supported only on WindowsÂ 2000 or later, MIDL generates a guard with the TARGET_IS_NT50_OR_LATER macro.
The guard macros, defined in Rpcndr.h, depend on the setting of WINVER and _WIN32_WINNT and are evaluated by the C/C++ compiler.
If, at C-compile time, you get an error message indicating that you need a specific platform to run a stub, first check to make sure you have not used a feature that is not available on this platform. The features triggering a particular guard are listed in the body of the guard. In the previous example, the -Oicf compiler switch triggered the guard. Notable features of this kind include the /robust switch and the [async] attribute available on WindowsÂ 2000 and later, the pipe type constructor, the /Oif compiler option, and the [user_marshal] and [wire_marshal] attributes. Stubs using these features will not run on earlier systems.
If you know that your target platform is correct for the features you are using and still receive an error, you may need to set the environment variables appropriately.
To build for WindowsÂ 2000 or later releases
- Add this line to your makefile:
CFLAGS = $(CFLAGS) -D_WIN32_WINNT=0x500