命令行警告 D9035:选项 'Gm' 已被弃用,将在未来版本中删除

Command line warning D9035: option 'Gm' has been deprecated and will be removed in a future release

我在使用 Visual Studio 2017 最新更新 15.9.2 构建项目时收到警告消息 "cl : Command line warning D9035: option 'Gm' has been deprecated and will be removed in a future release"。如何解决此警告?

根据documentation

You may safely remove this option from your projects.

Project > Properties > Configuration Properties > C\C++ > Code Generation > 将 Enable Minimal Rebuild 设置为 no,并且没有警告。

属性 > C\C++ > 代码生成 > 启用最小重建:删除值 - 并且没有警告。

我也遇到过。未能通过 UI 修复它。 最后,我在所有项目文件中搜索 "MinimalRebuild" 并手动将其删除 - 这有助于

尝试为 Enable Minimal Rebuild 选项选择 <inherit from parent or project defaults>(在 C/C++ > Code Generation 下)。在此之后,该选项应该以粗体显示 No (/Gm-) 而不是 。确保为您的项目(您可以在解决方案中有多个项目)以及它们继承自的所有 属性 页面执行此操作。

我在使用 Visual Studio 2019 时遇到了同样的问题,最后问题出现在我在同一解决方案中的第二个项目中,该项目的选项设置为 Yes (/Gm).

UI 也不适合我。在 .vcxproj 文件搜索中:"MinimalRebuild" 我在 Debug|Win32

下错过了第二个

只需将其添加到您弃用的函数上方即可

#pragma warning (disable : 4996);

例子

#pragma warning (disable : 4996);
your_deprecated_function();