Enabling C++14 in clang in Visual Studio

后端 未结 2 1574
小鲜肉
小鲜肉 2020-12-30 08:02

I\'ve installed clang 3.7 and I\'m using it with visual studio. When I try to compile:

auto f()
{
return 2;
}

I\'m getting error saying tha

2条回答
  •  爱一瞬间的悲伤
    2020-12-30 08:49

    I work on clang-cl. As antiduh says, clang-cl tries to mimic Visual Studio's cl. cl up to and including c++14 didn't have a switch for enabling language modes, it just always enabled all the latest stuff. Hence, clang-cl does too. MSVC gained some C++14 support in MSVC 2015, so if you tell clang-cl that you want it to emulate MSVC 2015 or later, it will automatically enable C++14. clang-cl by default emulates the version of MSVC found on your system. You can explicitly pass -fmsc-version=1900 to force emulation of 2015, which will then implicitly enable C++14.

    As of MSVC 2017, cl.exe supports a /std: flag, so clang-cl supports that too. It can be used to enable C++14 (the lowest level), C++17, C++20, or the newest-known version.

    The -Xclang flags are internal flags and are not considered a stable interface. So do not use those.

提交回复
热议问题