The /cpp_cmd switch specifies the preprocessor that the MIDL compiler uses to preprocess input files.
midl /cpp_cmd "C_preprocessor_binary"
Specifies the command that invokes the preprocessor. This command allows developers to override the default preprocessor. By default, MIDL invokes the Microsoft C/C++ compiler from the build machine's build environment.
The C_preprocessor_binary argument to the switch may specify the full path; the exe suffix and quotes are optional. Typically, developers use the switch to choose a particular version of the Microsoft C/C++ preprocessor or equivalent in the build environment. In this case, it is not necessary to use the /cpp_opt switch with /cpp_cmd.
When using a non-Microsoft preprocessor, especially when the specified preprocessor does not direct its output to stdout, the C compiler switch that redirects output to stdout as part of the MIDL compiler /cpp_opt switch must be specified. See C-Preprocessor Requirements for MIDL for details
The preprocessor is invoked by a command string that is formed from the information provided to the MIDL compiler by /cpp_cmd, /cpp_opt, /D, /I, and /U switches. The following table summarizes how the command string is constructed for each combination of /cpp_cmd and /cpp_opt switches.
When the /cpp_cmd switch is not specified, the MIDL compiler invokes the Microsoft C/C++ compiler. MIDL uses a Cl.exe binary found in the build environment.
When the /cpp_opt switch is not present, the MIDL compiler concatenates the string specified by the /cpp_cmd switch with the information specified by the MIDL /I, /D and /U options. The string /E is also concatenated to the C-compiler invocation string to indicate that the C/C++ compiler should perform preprocessing only. The /nologo switch is added to suppress the C/C++ compiler banner. The MIDL compiler uses the concatenated string to invoke the C preprocessor for top-level IDL as well as imported IDL files, and also for any present, corresponding ACF files.
When the /cpp_opt switch is present, which should be a rare case for the current 32-bit and 64-bit platforms, the MIDL compiler concatenates the string specified by the /cpp_cmd switch with the string specified by the /cpp_opt switch. The MIDL compiler uses the concatenated string to invoke the indicated preprocessor binary in place of the default preprocessor. When the /cpp_opt switch is present, neither the MIDL compiler options specified by the /I, /D, and /U switches nor the C compiler switch /E is concatenated with the string. You must supply the /E option, or equivalent, as part of the string.
|/cpp_cmd present?||/cpp_opt present?||Description|
|No (default)||No (default)||Invokes the default Microsoft C/C++ compiler with settings obtained from MIDL /I, /D and /U switches. Adds the preprocessor switches /E and /nologo.|
|Yes||No||Invokes the indicated preprocessor binary with the same switches as above.|
|No||Yes||Invokes the Microsoft C compiler with specified options. Does not use MIDL /I, /D, /U options. You must supply /E as part of /cpp_opt.|
|Yes||Yes||Invokes the specified preprocessor binary with specified options only. You must use quotes.|
midl /cpp_cmd d:\nt\tools\ia64\cl.exe /DFLAG=TRUE /Ic:\inc filename.idl
midl /cpp_cmd "mycpp" /DFLAG=TRUE /Ic:\inc filename.idl
midl /cpp_opt "/E /DFLAG=TRUE /Ic:\inc" filename.idl
midl /cpp_cmd "cl" /cpp_opt "/E /DFLAG=TRUE /Ic:\inc" filename.idl