C2337 'importidl': 将解决方案升级到 VS2019 ( 16.9.2 ) 后找不到属性错误

C2337 'importidl': attribute not found error after upgrading solution to VS2019 ( 16.9.2 )

我正在更新一个项目以使用 VS2019 进行编译,结果发现 importidl 在 VS2019 ( 16.9.2 ).比较更新到 VS2019 之前和更新到 VS2019 之后生成的 .tlb 文件小得多,导致 COM 接口损坏。

我收到的错误是 C2337 'importidl':attribute not found

importidl 被警告抑制包围:

#pragma warning(disable: 4467)
[ importidl(COM\dummy.idl) ];
#pragma warning(pop)

C4467: usage of ATL attribute is deprecated

Microsoft documentation 导致相信 imporidl 没有被弃用或删除。然而,它最近一次更新是在 2 年前,警告和错误让我相信文档中存在差异。

绕过已删除的 importidl 的替代方法是什么?

为了解决 VS2019 的这个问题,我在命令行选项中添加了一个 /permissive 标志。将一致性模式与 std:c++latest 一起设置为“否”无效。 std:c++latest 可能覆盖 /permissive.

使用最新的 /std:c++latest 语言标准将一致性模式保持为 Default,并将 /permissive 作为附加选项添加到命令行 属性 可以绕过错误C2017 Importidl attribute not found