Does cl option in windows makefile will accepts -std=c++11 flag?

Viewed 1695

I have written sample Makefile in windows which uses cl option from visual studio 2017. It causes the warnings as follow cl : Command line warning D9002 : ignoring unknown option '-std=c++11'

Follow the below steps to reproduce the issue.

  1. Open Developer Command Prompt for VS2017
  2. Write any simple c++ code and compile with using then we can see the warning
   cl <filename>.cpp /std=c++11 

Does it mean VS2017 by default it will support c++11, so cl option omitting c++11 flag (or) is there something else for throwing warning by cl.exe?

Can anyone please clarify regarding this issue?

Thanks,

Hari

2 Answers

See here. cl only accepts the options /std:c++14, /std:c++17, and /std:c++latest.

C++11 features are already enabled by default.

Examining the output of cl.exe /? for MSVC 2017, I found:

/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)

It appears that:

  • There is no switch for strict C++11 compatibility.
  • The correct syntax is /std:..., not -std=...
Related