Export (0) Print
Expand All

/backward_compat Switch

The /backward_compat switch directs the MIDL compiler to turn off some advanced features when generating RPC/COM stubs.

midl /backward_compat { maybenull_sizeis | zeroout_alignmentgap | 
     BSTR_byvalue_escaping | string_defaultvalue | signed_wchar_t }

Switch Options

maybenull_sizeis

Applies the [disable_consistency_check] attribute to an entire MIDL compilation.

zeroout_alignmentgap

Turns off zeroing out gaps in the marshaled buffer.

BSTR_byvalue_escaping

Directs the MIDL compiler to honor escape sequences such as ‘\n’ or ‘\t’ in BSTRs.

string_defaultvalue

Forces the MIDL compiler to coerce strings in [defaultvalue] attributes into VARIANT.VT_I4 type before coercing the value into the correct type.

signed_wchar_t

Directs MIDL to treat the wchar_t type as signed for compatibility with Visual Basic.

Remarks

  • maybenull_sizeis: See [disable_consistency_check].
  • zeroout_alignmentgap: When IDLs are compiled with –target NT60 or higher, MIDL will create stubs that zero out any alignment gaps between members or a structure in the wire buffer. The command line switch /backward_compat zeroout_alignmentgap directs MIDL to disable this feature.

    In the following example structure, the wire buffer contains a 7 byte alignment gap to align the hyper member to 8 after the char member. With –target NT60 or higher, MIDL will zero out that gap unless the switch is used.

    IDL file:
    typedef struct _structwithgaps{
        char c;
        // 7 byte gap to align the following hyper to 8 
        hyper h;
    } structwithgap;
    
    This switch can provide a slight performance improvement with potentially significant increases in disclosure risk.
  • BSTR_byvalue_escaping: By default, the MIDL compiler does not process escape sequences such as ‘\n’ or ‘\t’ in string constants for OLE Automation when converting a string constant to types VT_LPSTR or VT_LPWSTR. With this backward compatibility switch option, the escape sequences are evaluated.
  • string_defaultvalue: Forces the MIDL compiler to coerce numeric strings in [defaultvalue] attributes into VARIANT.VT_I4 type before coercing the value into the correct type. This can lead to loss of precision in some cases, so this switch option is not recommended.
  • signed_wchar_t: Directs MIDL to treat the wchar_t type as signed for compatibility with Visual Basic.

 

 

Community Additions

ADD
Show:
© 2014 Microsoft