Sysprogs forums › Forums › VisualGDB › Changing an existing project to C++17
- This topic has 2 replies, 2 voices, and was last updated 5 years, 1 month ago by support.
-
AuthorPosts
-
September 25, 2019 at 21:21 #25906Ophidian14Participant
I have an existing project which was using C++11 and the headers/libs from GCC 4.8.5. This project is now using the headers/libs from devtoolset-8 (gcc 8.3.1) and C++17. How do I go about editing my project file so that it reflects this? I got my Intellisense include directories in order, but it’s telling me errors such as “no such template ‘optional’ in namespace std” which makes me think it’s not picking up C++17. I did try creating a new project and selecting C++17 with the wizard, and this worked, but I would like to keep my existing project file. I noticed the new project contained this:
<ItemDefinitionGroup Condition=”‘$(Configuration)|$(Platform)’==’Debug|VisualGDB'”>
<ClCompile>
<CPPLanguageStandard>CPP1Z</CPPLanguageStandard>
</ClCompile>
</ItemDefinitionGroup>which I added to my new project but it did not make a difference ( I got the same error).
September 25, 2019 at 22:42 #25909Ophidian14ParticipantAlso I’d like to ask a slightly different related question. I follow the following steps:
- Create a new Linux Cmake project targeting C++17.
- Manually add the /opt/rh/…. include paths for devtoolset-8.
- Add #include <optional> and declare a std::optional<int>.
- I seemingly have to restart my project for the changes in #2 to correctly reflect in #3 (otherwise my usage of optional is red underlined and unrecognized) but I am not worried about this.
At this point I change from Cmake build to Custom build step. Immediately I lose support for C++17 and std::optional, they go red squiggly and the error console says “namespace std has no template optional” or something like that. My question is, why does changing the build type lose me the C++17 support and how would I reintroduce it?
September 26, 2019 at 23:05 #25932supportKeymasterHi,
For MSBuild-based projects you can set the C++ language standard via VS Project Properties (not VisualGDB Project Properties) -> C/C++ -> Advanced -> Language Standard for C++ files (that will set the CPPLanguageStandard value in the .vcxproj file). If you believe this causes an error, please identify whether it affects building or only IntelliSense and whether you are using Clang IntelliSense or the regular VC++ IntelliSense.
If the project cannot be built, your compiler may not support C++17. If the problem is specific to IntelliSense only, please try reproducing it on a clean project and let us know the exact repro steps (see the 3-step format here).
Regarding the CMake projects, please try using the new Advanced CMake Project Subsystem. It automatically keeps the IntelliSense settings synchronized with the actual build settings, eliminating the need for any manual setup. If you would like to use the old CMake project system (based on VC++ projects), you would need to manually add the “–std=” option to VisualGDB Project Properties -> IntelliSense -> Additional flags for C++ files.
-
AuthorPosts
- You must be logged in to reply to this topic.