我编码了C++ on 视觉工作室(Windows 10)并收到此错误:
#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.
有了这个标题:
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <filesystem>//If I will disable it nothing happens.
#include <experimental/filesystem> //If I will disable it happens another error.
namespace fs = std::experimental::filesystem;
using namespace std;
我试过了:#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
在主cpp文件中。这没有帮助。
然后我粘贴这段代码here https://stackoverflow.com/questions/53365538/how-to-determine-whether-to-use-filesystem-or-experimental-filesystem:
#ifdef __cpp_lib_filesystem
#include <filesystem>
using fs = std::filesystem;
#elif __cpp_lib_experimental_filesystem
#include <experimental/filesystem>
using fs = std::experimental::filesystem;
#else
#error "no filesystem support ='("
#endif
也没有帮助。
消除该错误的最简单方法是什么?
将 _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING 添加到预处理器定义中。
项目 -> 属性 -> C/C++ -> 预处理器 -> 预处理器定义。
这为我解决了这个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)