Visual Studio 2019 C ++和std :: filesystem [英] Visual Studio 2019 C++ and std::filesystem
问题描述
现在,在将其升级到编译器的较新版本之后,我不会想到。
Now, I would have not expected That, after 'upgrading' to a 'newer' version of the compiler.
在VS2017中,可以通过以下方式使用std :: filesystem std :: experimental :: filesystem,现在升级到VS2019后,令我惊讶的是,它根本不可用。不是在std :: experimental还是std :: filesystem中都没有。
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.
是的,我尝试从项目设置中设置c ++ 17,甚至是最新草案,有任何想法吗?
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.
要在Visual Studio中切换到C ++ 17'std :: filesystem(无论VS2019或VS2017),您需要:
To switch to C++17' std::filesystem in Visual Studio (regardless VS2019 or VS2017) you need to:
- 更改以下语言的语言标准项目属性->配置属性-> C / C ++->语言-> C ++语言标准至少为 ISO C ++ 17标准(/ std:c ++ 17)
(也可以在 Project中找到属性->配置属性->常规-> C ++语言标准) - change
#include< experimental / filesystem>
到#include< filesystem>
- 更改源代码中所有
std的外观:: experimental :: filesystem
到std :: filesystem
- 修复实验文件系统版本与最终文件系统版本之间可能存在差异
- 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
tostd::filesystem
- fix the possible differences between the experimental and final filesystem versions
这篇关于Visual Studio 2019 C ++和std :: filesystem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!