none
-std:c++11 vs. -std=c++11 RRS feed

  • Question

  • It looks like Microsoft is using "-std:" (or "/std:") while other compilers, including g++, use "-std=". Does the ISO C++ standard define this explicitly?

    As you might guess, I am using Visual Studio C++ and working on code created for other compilers. A clarification of the "correct" way to write this compiler option would be useful.

    cl : Command line warning D9002 : ignoring unknown option '-std=c++11'
    https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=vs-2019
    Recommended: -std:c++17 or -std:c++latest
    https://stackoverflow.com/questions/10363646/compiling-c11-with-g


    Tom

    Sunday, September 15, 2019 4:29 PM

Answers

  • No, the C++ standard has absolutely nothing to say about how a compiler is to be invoked.

    Igor Tandetnik

    • Marked as answer by TomLigon Monday, September 16, 2019 11:51 AM
    Sunday, September 15, 2019 4:57 PM
  • An interesting fact here is that prior to a Visual Studio 2015, Visual C++ didn't even have a /std: option. This is why there is no option prior to C++ 14 available.

    The "correct" way is to look at the reference for the compiler options and choose what ever the compiler reference states that it supports. Different compiler frontends having different command line options is a given. It isn't just the /std: option, IIRC Visual C++ uses /Od to disable optimisations where GCC uses /O0. So it isn't surprising if you end up with multiple sets of command line options depending on what compiler you use.

    As an interesting side note, Clang actually has two frontends. There is clang, which emulates the GCC frontend, and clang-cl, which emulates the VC frontend. This means that the clang-cl frontend uses the /std: version.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Monday, September 16, 2019 4:06 AM

All replies

  • No, the C++ standard has absolutely nothing to say about how a compiler is to be invoked.

    Igor Tandetnik

    • Marked as answer by TomLigon Monday, September 16, 2019 11:51 AM
    Sunday, September 15, 2019 4:57 PM
  • An interesting fact here is that prior to a Visual Studio 2015, Visual C++ didn't even have a /std: option. This is why there is no option prior to C++ 14 available.

    The "correct" way is to look at the reference for the compiler options and choose what ever the compiler reference states that it supports. Different compiler frontends having different command line options is a given. It isn't just the /std: option, IIRC Visual C++ uses /Od to disable optimisations where GCC uses /O0. So it isn't surprising if you end up with multiple sets of command line options depending on what compiler you use.

    As an interesting side note, Clang actually has two frontends. There is clang, which emulates the GCC frontend, and clang-cl, which emulates the VC frontend. This means that the clang-cl frontend uses the /std: version.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Monday, September 16, 2019 4:06 AM
  • Thanks to both Igor and Darran! This si exactly the information I was looking for.

    Tom

    Monday, September 16, 2019 11:52 AM