简体   繁体   English

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

[英]std:: has no member "filesystem" in C++/17

I'm trying to include <filesystem> , but when I use a namespace, it shows this error:我正在尝试包含<filesystem> ,但是当我使用命名空间时,它显示此错误:

std:: has no member "filesystem" std:: 没有成员“文件系统”

I know in older times it is <experimental/filesystem> and namespace is std::experimental::filesystem;我知道在过去它是<experimental/filesystem>并且命名空间是 std::experimental::filesystem;

but, when i does this, it also give error like that:但是,当我这样做时,它也会出现这样的错误:

    #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.

I'm using Visual Studio 2019, and C/C++ language settings is set to latest version.我使用的是 Visual Studio 2019,并且 C/C++ 语言设置设置为最新版本。

So what caused the problem?那么是什么导致了这个问题呢?

Edit 1: all code which cause error:编辑 1:所有导致错误的代码:

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

namespace fs = std::filesystem;

int main() {

    return 0;
}

edit 2: All code, in older, which has error too:编辑 2:所有代码,旧的,也有错误:

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

namespace fs = std::experimental::filesystem;

int main() {


    return 0;

}

edit 3: Visual Studio 2019 project configuration settings -> general properties:编辑 3:Visual Studio 2019 项目配置设置 -> 常规属性:

Platform Toolset: Visual Studio 2019 (v142) C++ Language Standart: ISO C++17 Standart (std::c++17) Windows SDK version 10.0 (Lastest installed version)平台工具集:Visual Studio 2019 (v142) C++ 语言标准:ISO C++17 标准 (std::c++17) Windows SDK 版本 10.0(最新安装的版本)

After Struggling 10 hours, I got the answer.经过 10 个小时的奋斗,我得到了答案。 I'll post it for who'll get same problem with me in the future;我会把它贴出来给将来和我有同样问题的人;

in my case, Visual Studio Configuration settings are only set in x86 configuration, so set configurations to all configurations, than use these steps:就我而言,Visual Studio 配置设置仅在 x86 配置中设置,因此将配置设置为所有配置,而不是使用以下步骤:

1- Project properties -> configuration properties -> general -> and set language standart as "C++ Language Standart: ISO C++17 Standart (std::c++17)" 1- 项目属性-> 配置属性-> 常规-> 并将语言标准设置为“C++ 语言标准:ISO C++17 标准(std::c++17)”

2- Project properties -> C/C++ -> Language -> and set language standart as "C++ Language Standart: ISO C++17 Standart (std::c++17)" 2- 项目属性 -> C/C++ -> 语言 -> 并将语言标准设置为“C++ 语言标准:ISO C++17 标准 (std::c++17)”

3- (Most Important) Project properties -> C/C++ -> Commend Line -> additional options, paste this: /Zc:__cplusplus 3-(最重要的)项目属性 -> C/C++ -> Commend Line -> 附加选项,粘贴: /Zc:__cplusplus

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM