Now, I would have not expected That, after 'upgrading' to a 'newer' version of the compiler.
In VS2017 std::filesystem was available through std::experimental::filesystem, Now after upgrading to VS2019 to my surprise it is not available at all. Not in std::experimental nor std::filesystem.
and YES, I've tried setting c++17 from project's settings even the 'latest draft' thing, any ideas?
For the sake of completeness and people searching this in the future.
To switch to C++17' std::filesystem in Visual Studio (regardless VS2019 or VS2017) you need to:
change the language standard in Project properties -> Configuration Properties -> C/C++ -> Language -> C++ Language Standard to at least ISO C++17 Standard (/std:c++17)
(Can also be found in Project properties -> Configuration Properties -> General -> C++ Language Standard)
change #include <experimental/filesystem> to #include <filesystem>
change in the source code all appearance of std::experimental::filesystem to std::filesystem
fix the possible differences between the experimental and final filesystem versions
For all those who struggle with porting their existing Visual Studio 2017 projects into Visual Studio 2019, having proper project settings and pulling their hair out to no avail:
in file VC\Tools\MSVC\14.26.28801\include\filesystem
there's:
#if !_HAS_CXX17
now for why this flag is not automatically being set when changing projects settings I have no idea.
Thus I've used:
#define _HAS_CXX17 1
#include <filesystem>
in my files as a workaround. Works fine.
Update: On another system, within project's file there was
<LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalOptions>/std:c++14 %(AdditionalOptions)</AdditionalOptions>
The latter line was resulting in problems (obviously). Switching higher-level project settings does not remove such optional settings (obviously).
I hit the same issue [include filesystem] with the 2019 version (Microsoft Visual Studio Community 2019 Version 16.6.0) in spite of C++17 language selection.
I had to explicitly change the platform and the Active Solution platform to x64 in the configuration window (though, I started with x64). With this, the error is gone.
You will have to update your Visual C++ redistributable if you haven't. Then under project properties > Configuration Properties > C++ Language Standard: Select C++17 or higher.
You could try setting it to that by default. See this:How to change default C++ language standard in Visual Studio 2019?
The correct solution to that is:
For Xcode:
go to project properties
under build Settings, scroll down to Apple Clang- Language- c++.
there you have to select c++ language dialect and set it to C++17[-std=c++17].
cheers
Singh
Related
I've read about how to change these settings in .props files for VS 2019, but those solutions didn't work for me with VS 2022.
I simply want the DEFAULT C++ Language Standard to be CPP20, not CPP14.
I don't like having to change it for every project as sometimes I forget and thus my code won't run.
https://www.learncpp.com/cpp-tutorial/configuring-your-compiler-choosing-a-language-standard/
Setting a language standard in Visual Studio
As of the time of writing, Visual Studio 2022 defaults to C++14 capabilities, which does not allow for the use of newer features introduced in C++17 and C++20.
To use these newer features, you’ll need to enable a newer language standard. Unfortunately, there is currently no way to do this globally -- you must do so on a project-by-project basis.
Warning
With Visual Studio, you will need to reselect your language standard every time you create a new project.
To select a language standard, open your project, then go to Project menu > (Your application’s Name) Properties, then open Configuration Properties > C/C++ > Language.
I'm stuck on this, when i compile a project in Visual Studio i have this error at the ouput, telling that:
on nmvc you must the /Zc:__cplusplus option to the compiler (compiling source file QtdesignerWidget.cpp)
I tried the solution to add /Zc:__cplusplus in the project properties -C++ / Command line / Additional options withou success
And when i try to make a .pro file in QT VS tools it makes this error:
Warning : Cannot Find any Qt4 projects to export
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
Select the Configuration Properties > C/C++ > Command Line property page.
Add /Zc:__cplusplus or /Zc:__cplusplus- to the Additional options: pane.
The answer is taken from here: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
Same problem. Here are my platforms:
Qt version: 6.2.0
Qt Visual Studio Tools version: 3.4
Compiler version: VS2019_64
Luckily, I also installed Qt5.14.2 on my computer. When I changed configurations to: Qt5.14.2 and VS2017_64. Problem solved. So I guess VS2019 or Qt VS tools3.4 doesn't work well with Qt6.2.0.
You can have a try.
Are you sure your language standard is set to C++17 in the project settings?
Go to project properties --> General --> C++ Language Standard
In my case it was default set to C++14. This must be set to C++17.
I was trying to use inline variables, but found out VS defaults to C++14 and one must manually change this on a project by project basis. Why doesn't Microsoft automatically update VS to the C++17 standard for all projects?
I kept hearing Connector/C++ should run on the compiler that it was compiled on, and one document says that's Visual C++ 2013. I'm using Visual C++ 2017 and I'm not downgrading. The document may have been old, so I'm curious if anyone has had any success and what you did to make it work.
Yes it will definately work. You just have to add include path and library path of MySQL to your VC++ directories ( Project -> Properties -> VC++ directories).
Now that you have included path you can directly use mysql.h header to call mysql c functions.
No, for C++ you have to find a version that got compiled with the same settings as your project. You can switch to using the C version of the connector which does not suffer from C++'s lack of ABI. You can find the C tutorial here.
If you would like to try your luck with C++, then make sure the build settings of the library you use match your project:
version of Visual Studio
version of stl
exception handling
vtable layout
stack and stack frame padding
Bitness (32 vs 64)
Iterator debug level
runtime linkage (MT vs MD)
build configuration (Debug vs Release)
characterset (multibyte vs unicode)
Fortunately the linker will check the compiler version _MSC_VER and will not allow you to link to the older library.
I'm using Visual Studio 2015 to work with Visual Studio 2010 C++ projects.
Those projects are not converted and need to stay true 2010 projects.
Compiling works as expected.
However, when I try to modify the project properties I only get Codeanalysis, everything else is missing.
See here:
In VS2010 it looks as expected:
Can reproduce that: every new c++ project I create in VS2010 does not show the properties in VS2015.
Ok, the problem is indeed due to language settings.
Settings with issue:
VS2010 german version
VS2015 english version
-> project properties missing
This fixed it:
VS2010 german version
VS2015 switched to german language
-> project properties there
Unfortunately it is not possible to change language in VS2010 without re-installing. And I don't want to stay with VS2015 in german language :(
UPDATE:
I reported that issue at microsoft and they just confirmed it. So this might be fixed in a future update