我遇到了文件系统库的问题,它应该包含在 c++17 编译器中,2 天后我尝试在 raspberry pi 中安装 gcc-7.0.2 但它没有用,它不能识别命令 gcc-7 或 g++-7 甚至 -std=c++17
所以我不得不使用 apt-get install
安装 g++-6 和 gcc-6无论如何,在安装 6 版本后,编译器包含 c++17.我使用代码块作为 IDE,我不得不添加一个新的编译器并添加选项 -std=c++17 来启用它,但是在主代码中,当我包含文件系统库时,它说没有这样的文件或目录.
i'm facing a problem with filesystem library, it should be included in c++17 compiler, after 2 days i tried to install gcc-7.0.2 in raspberry pi but it didn't work, it couldn't recognize the command gcc-7 or g++-7 or even -std=c++17
so i had to install g++-6 and gcc-6 using apt-get install
anyway, after installing the 6 version the compiler include c++17.
i'm using codeblocks as IDE, i had to add a new compiler and add the option -std=c++17 to enable it,but in the main code when i include the filesystem library it says no such file or directory.
我的问题是,如何正确添加 c++17 编译器及其库(如文件系统)??
my question is, how i can add the c++17 compiler and its library (like filesystem) correctly ??
GCC v7
仍然没有实现
GCC v7
still does not implement <filesystem> but it does have the Filesystem Technical Specification which is in <experimental/filesystem>
#include <experimental/filesystem>
// for brevity
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p = "/path/to/my/file"; // etc...
}
这也适用于 GCC v6
.
要与库链接,您需要将 -lstdc++fs
添加到命令行.
To link with the library you need to add -lstdc++fs
to the command line.
注意:当前的技术规范与
Note: There may be some minor differences between the current Technical Specification and the final draft of <filesystem> that is decided upon by the Standards Committee.
注意 2: GCC v8
现在实现了 -std=c++17
标志.
Note 2: GCC v8
now implements <filesystem> with the -std=c++17
flag.
这篇关于为什么 GCC 似乎没有文件系统标准库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!