【问题标题】:Does cl option in windows makefile will accepts -std=c++11 flag?Windows makefile 中的 cl 选项是否会接受 -std=c++11 标志?
【发布时间】:2019-01-17 16:09:41
【问题描述】:

我在 windows 中编写了示例 Makefile,它使用了 Visual Studio 2017 中的 cl 选项。它会导致如下警告 cl : 命令行警告 D9002 : 忽略未知选项 '-std=c++11'

按照以下步骤重现问题。

  1. 为 VS2017 打开开发者命令提示符
  2. 编写任何简单的 c++ 代码并使用 using 编译然后我们可以看到警告
   cl <filename>.cpp /std=c++11 

这是否意味着 VS2017 默认支持 c++11,所以 cl 选项省略 c++11 标志(或)还有其他东西可以通过 cl.exe 引发警告吗?

谁能澄清一下这个问题?

谢谢,

哈里

【问题讨论】:

    标签: c++11 makefile visual-studio-2017


    【解决方案1】:

    herecl 只接受/std:c++14/std:c++17/std:c++latest 选项。

    默认情况下已启用 C++11 功能。

    【讨论】:

      【解决方案2】:

      检查 cl.exe /? 对于 MSVC 2017 的输出,我发现:

      /std:<c++14|c++17|c++latest> C++ standard version
          c++14 – ISO/IEC 14882:2014 (default)
          c++17 – ISO/IEC 14882:2017
          c++latest – latest draft standard (feature set subject to change)
      

      看来:

      • 没有用于严格 C++11 兼容性的开关。
      • 正确的语法是/std:...,而不是-std=...

      【讨论】:

        猜你喜欢
        • 2014-11-17
        • 2015-02-15
        • 2018-03-08
        • 2013-11-22
        • 1970-01-01
        • 2016-07-08
        • 1970-01-01
        • 2014-07-12
        • 1970-01-01
        相关资源
        最近更新 更多