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:
#include <experimental/filesystem>
to #include <filesystem>
std::experimental::filesystem
to std::filesystem
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With