问题描述
我正在尝试包含<filesystem>
,但是当我使用名称空间时,它显示此错误:
std ::没有成员“文件系统”
我知道在更早的时候它是<experimental/filesystem>
并且名称空间是std :: experimental :: filesystem;
但是,当我这样做时,它也会给出类似的错误:
#error The <experimental/filesystem> header providing std::experimental::filesystem is deprecated by Microsoft \
and will be REMOVED. It is superseded by the C++17 <filesystem> header providing std::filesystem. \
You can define _SILENCE_EXPERIMENTAL_FILESYstem_DEPRECATION_WARNING to ackNowledge that you have received this warning.
我正在使用Visual Studio 2019,并且C / C ++语言设置设置为最新版本。
那是什么原因引起的?
#include <iostream>
#include <Windows.h>
#include <filesystem>
namespace fs = std::filesystem;
int main() {
return 0;
}
#include <iostream>
#include <Windows.h>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
int main() {
return 0;
}
编辑3:Visual Studio 2019项目配置设置->常规属性:
平台工具集:Visual Studio 2019(v142) C ++语言标准:ISO C ++ 17标准(std :: c ++ 17) Windows SDK版本10.0(最新安装的版本)
解决方法
经过10个小时的奋斗,我得到了答案。我会将其发布给以后会遇到相同问题的人;
在我的情况下,Visual Studio配置设置仅在x86配置中设置,因此将配置设置为所有配置,而不使用以下步骤:
1-项目属性->配置属性->常规->并将语言标准设置为“ C ++语言标准:ISO C ++ 17标准(std :: c ++ 17)”
2-项目属性-> C / C ++->语言->并将语言标准设置为“ C ++语言标准:ISO C ++ 17标准(std :: c ++ 17)”
3-(最重要)项目属性-> C / C ++->推荐行->其他选项,请将其粘贴:/Zc:__cplusplus