Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
685 views
in Technique[技术] by (71.8m points)

c++ - 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 e.g.), 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?

Prefferably 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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.5k users

...