How to add std=c++11 flag to clang-cl?

2020-07-23 04:02发布

问题:

I tried to compile a C++11 program with clang-cl under Windows. Clang-cl is the wrapper around clang to be more compatible with cl (Visual Studio compiler). I tried to add -std=c++11 and /std=c++11 and both get rejected. This is to no surprise as cl has no C++11 flag. But I can not use C++11 features with clang-cl.

How can I enable C++11 support in clang-cl?

回答1:

In the documentation mentioned before says: http://clang.llvm.org/docs/UsersManual.html#clang-cl

clang defaults to C++11 for Windows targets.

Maybe you don't need to pass any flag to clang-cl.



回答2:

From official docs:

/std:<standard>


回答3:

For any future visitors, using /std:c++17 for clang-cl works for me. Notice that there is no equals sign after std.