简体   繁体   中英

Visual Studio 2019 - how to manually edit .props/solution file to force c++17/c++latest standard?

We decided to upgrade our solution, that we are able to use c++17 standard.

The solution itself has a lot of projects and I am aware how to setup this manually through the properties of each of them (Project properties -> Configuration Properties -> C++ Language Standard eg), but this is something I want to avoid. I want to specify this for all projects through .props file, that each of them can be attached or via .sln file, is there any way how to do this globally or you really need to specify C++ standard in a separate way for every project?

Preferably if the answer contain the tag like <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset> and where to put it (of course I am not interested about toolset itself but the tag specifying the c++17/c++latest standard).

I already searched through some default imported VS.props files, but without any success...

Just in case somebody will search for it you need to add:

  <ItemDefinitionGroup Condition="'$(VisualStudioVersion)' >= '15.0'">
    <ClCompile>
      <LanguageStandard>stdcpp17</LanguageStandard>
    </ClCompile>
  </ItemDefinitionGroup>

to the .props file you are using (condition check is not necessary).

In case of latest standard use stdcpplatest instead stdcpp17 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM