std:: 在 C++/17 中没有成员“文件系统”

Ahm*_*kın 4 c++ std-filesystem

我试图包含<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.
Run Code Online (Sandbox Code Playgroud)

我使用的是 Visual Studio 2019,C/C++ 语言设置设置为最新版本。

那么是什么原因导致了这个问题呢?

编辑1:导致错误的所有代码:

#include <iostream>
#include <Windows.h>
#include <filesystem>

namespace fs = std::filesystem;

int main() {

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编辑2:所有旧代码也有错误:

#include <iostream>
#include <Windows.h>
#include <experimental/filesystem>

namespace fs = std::experimental::filesystem;

int main() {


    return 0;

}
Run Code Online (Sandbox Code Playgroud)

编辑3:Visual Studio 2019项目配置设置->常规属性:

平台工具集:Visual Studio 2019 (v142) C++ 语言标准:ISO C++17 Standard (std::c++17) Windows SDK 版本 10.0(最新安装版本)

Ahm*_*kın 14

经过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