Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 864
Hari Krishna Nalla Avatar asked Oct 23 '25 20:10

Hari Krishna Nalla


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.

like image 196
0x5453 Avatar answered Oct 26 '25 14:10

0x5453


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=...
like image 43
Govind Parmar Avatar answered Oct 26 '25 15:10

Govind Parmar