c++ - VS2017从15.4.1升级到15.5.1导致构建错误

标签 c++ compiler-errors visual-studio-2017 midl vcxproj

我正在使用以下工具/版本进行编程:Windows 10/VS2017 Professional/C++

升级到 15.5.1 后,出现以下错误:

MIDL2338: switches are contradictory - no_robust vs. - target

Microsoft 编译器错误描述列表说:编译 IDL 文件时不能同时使用/osf 和/ms_ext 命令行开关。

这些开关都没有在我的项目属性中指定。

我尝试降级回 15.4.1,但发现除非是 N-1,否则无法恢复到旧版本。这是基于我读过的许多博客(包括 Stack Overflow)。

在我弄清楚这个开关问题之前,我遇到了瓶颈并处于停顿状态。

非常感谢您的帮助。

最佳答案

我刚才遇到了同样的问题,但幸运的是我可以访问另一个较旧的安装。

这里是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" 

这是它在 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" 

所有发生变化的是添加了一个新参数/target "NT60",大概是一个新的默认值。

在我看来,好像有两种方法可以解决这个问题:

  1. 在 idl 文件的“属性页”对话框中,转到“配置属性”>“MIDL”>“高级”,然后清除“最小目标系统”的值。
  2. 摆脱 -no_robust 标志。根据文档 ( 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."

就消除错误而言,这两种更改对我都有效,但第一种方法的影响最小。

附言。我认为 MS 错误描述 ( https://msdn.microsoft.com/en-us/library/windows/desktop/aa366756%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 ) 在这种情况下可能不正确。您看到的原始错误消息指的是两个特定的标志,/no_robust/target,而不是 /osf/ms_ext.

注意:MIDL 编译器 /robust 开关执行以下操作 ( 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.

关于c++ - VS2017从15.4.1升级到15.5.1导致构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47803621/

相关文章:

compiler-errors - 是否有 -Wall -Werror 的 rustc 等价物?

visual-studio-2017 - 未找到导入的项目 "C:\Program Files\dotnet\sdk\2.1.201\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets"

azure - 如何更改本地 Service Fabric 默认启动 URL?

visual-studio - GetEnvironmentVariable 应该在 xUnit 测试中工作吗?

c++ - 将 OpenGL 转换为 PNG

c++ - cppreference 中对宽松排序的解释是错误的吗?

c++ - 如何在 C++ 中修复 "no match for operator+"?

c++ - 实现具有共同功能的 2 个抽象类?

c++ - 将整个文件读入线 vector 的最有效方法

c++ - 继承类中的构造函数