Visual Studio 2019 C ++和std :: filesystem [英] Visual Studio 2019 C++ and std::filesystem

查看:735
本文介绍了Visual Studio 2019 C ++和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:


  1. 更改以下语言的语言标准项目属性->配置属性-> C / C ++->语言-> C ++语言标准至少为 ISO C ++ 17标准(/ std:c ++ 17)

    (也可以在 Project中找到属性->配置属性->常规-> C ++语言标准

  2. change #include< experimental / filesystem> #include< filesystem>

  3. 更改源代码中所有 std的外观:: experimental :: filesystem std :: filesystem

  4. 修复实验文件系统版本与最终文件系统版本之间可能存在差异

  1. 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)
  2. change #include <experimental/filesystem> to #include <filesystem>
  3. change in the source code all appearance of std::experimental::filesystem to std::filesystem
  4. fix the possible differences between the experimental and final filesystem versions

这篇关于Visual Studio 2019 C ++和std :: filesystem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆