13

I'm programming with the following tools/versions: Windows 10 / VS2017 Professional / C++

After I upgraded to 15.5.1 I got the following error:

MIDL2338: switches are contradictory - no_robust vs. - target

The Microsoft compiler error description list says: You cannot use both the /osf and /ms_ext command-line switches when you compile an IDL file.

None of those switches are specified in my project properties.

I tried to downgrade back to 15.4.1 but have found that it's impossible to revert to an old version unless it's N-1. This is based on the many blogs I've read (including Stack Overflow).

I have hit a wall and am at a standstill until I figure out this switch issue.

Your help would be greatly appreciated.

Exa
  • 4,020
  • 7
  • 43
  • 60
trishm
  • 133
  • 1
  • 7
  • Have you checked project property pages | Linker | Embedded IDL ? Also do the docs have anything useful to say [/ms_ext](https://msdn.microsoft.com/en-us/library/windows/desktop/aa367335(v=vs.85).aspx) and [/osf](https://msdn.microsoft.com/en-us/library/windows/desktop/aa367357(v=vs.85).aspx) – Chris O Dec 14 '17 at 02:07
  • I did check the Embedded IDL setting. There are no switches specified. Also, it built successfully with VS2017 v15.4.1. I did quite a bit of research on the /ms_ext and /osf switches and modifications that might be necessary due to the the upgrade. – trishm Dec 14 '17 at 16:17

2 Answers2

14

I ran into the same problem just now, but luckily I do have access to another, older, installation.

Here is the command line under VS 2017 15.4.4:

/iid "RtdHandleServer_i.c" /env win32 /h "RtdHandleServer.h" /W1 /char signed /tlb "Win32\Release\RtdHandleServer.tlb" /Oicf /D "NDEBUG" /no_robust /nologo /proxy "RtdHandleServer_p.c" 

Here is what it is changed to under VS 2017 15.5.1:

/iid "RtdHandleServer_i.c" /env win32 /h "RtdHandleServer.h" /W1 /char signed /tlb "Win32\Release\RtdHandleServer.tlb" /Oicf /target "NT60" /D "NDEBUG" /no_robust /nologo /proxy "RtdHandleServer_p.c" 

So all that has changed is that a new parameter /target "NT60" has been added, presumably as a new default.

It looks to me as if there are two ways to address this:

  1. In the Property Pages dialog for the idl file, go to Configuration Properties > MIDL > Advanced, and clear the value of "Minimum Target System".
  2. Get rid of the -no_robust flag. According to the documentation (https://msdn.microsoft.com/en-us/library/windows/desktop/aa367349%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396):

"The /no_robust command line switch must be used to disable the /robust feature if generated stubs need to run on Microsoft Windows NT, Windows 95/98, or Windows Me."

Either change works for me in terms of getting rid of the error, but the first method has the least impact.

PS. I think that the MS error description (https://msdn.microsoft.com/en-us/library/windows/desktop/aa366756%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) is likely to be incorrect in this instance. The original error message that you are seeing refers to two specific flags, /no_robust and /target, not to /osf and /ms_ext.

Note: The MIDL compiler /robust switch does the following (Microsoft docs MIDL compiler: /robust switch)

Using the /robust switch generates additional information that allows the Network Data Representation (NDR) engine to perform run-time error checking on correlated arguments in dynamic arrays, unions, and in out interface pointers in DCOM applications. The /robust switch is only available under Windows 2000 and later versions of Windows.

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
bb292
  • 156
  • 1
  • 4
  • If you have multiple projects with IDL files, the best option is to create a PropertySheet or use an existing one. Setting only the /robust and the /target that you need and assign the property sheet to each project. You also need to ensure that the /robust and /target settings are set to "Inherit from parent or project defaults". – blit Dec 14 '17 at 13:50
  • bb292, Thank you for your response. I tried both changes but got the same error. – trishm Dec 14 '17 at 17:32
  • /iid "AceRmServer_i.c" /env win32 /h "AceRmServer_h.h" /W1 /char signed /tlb "Debug\BtiRmAgent.tlb" /D "_DEBUG" /nologo – trishm Dec 14 '17 at 17:40
  • bb292: IT WORKED!! In my first attempt, I removed both the NT60 and the no_robust settings. This time I removed only the NT60. Thank you, thank you, thank you! – trishm Dec 14 '17 at 19:05
1

In order to remove the /no_robust flag (if generated stubs don't need to be run on Microsoft Windows NT, Windows 95/98, or Windows Me), simply remove the

<ValidateAllParameters>false</ValidateAllParameters>

entries under the <Midl> element in the .vcxproj files.

Source: ref

CJBS
  • 15,147
  • 6
  • 86
  • 135