- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
考虑这个最小的例子:
#include <filesystem>
#include <iostream>
int main()
{
std::cout << std::filesystem::current_path() << '\n';
}
它在 GCC 9.2 中按预期工作,但 Clang 8.0.1 拒绝编译 <filesystem>
header (来自 GCC 9.2 的 libstdc++):
# clang++ 1.cpp -std=c++17
In file included from 1.cpp:1:
In file included from Z:\Lander\msys2\mingw64\include\c++\9.2.0\filesystem:37:
Z:\Lander\msys2\mingw64\include\c++\9.2.0\bits/fs_path.h:636:31: error: invalid use of incomplete
type 'std::filesystem::__cxx11::filesystem_error'
_GLIBCXX_THROW_OR_ABORT(filesystem_error(
^~~~~~~~~~~~~~~~~
Z:\Lander\msys2\mingw64\include\c++\9.2.0\x86_64-w64-mingw32\bits/c++config.h:177:49: note: expanded
from macro '_GLIBCXX_THROW_OR_ABORT'
# define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
^~~~
Z:\Lander\msys2\mingw64\include\c++\9.2.0\bits/fs_fwd.h:61:9: note: forward declaration of
'std::filesystem::__cxx11::filesystem_error'
class filesystem_error;
^
1 error generated.
这是 Clang 错误还是 libstdc++ 错误?
我找到了 this bug report在 MSYS2 错误跟踪器上,但其中没有有用的信息。
有没有办法修补<filesystem>
header 来消除这个错误,而我们正在等待官方修复?
我在 Windows 上。我正在使用 MSYS2 软件包中提供的最新 GCC 和 Clang。
GCC 标识为:
# g++ --version
g++.exe (Rev2, Built by MSYS2 project) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Clang 标识为:
# clang++ --version
clang version 8.0.1 (tags/RELEASE_801/final)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: Z:\Lander\msys2\mingw64\bin
Clang 使用此 GCC 附带的 libstdc++。
最佳答案
此问题可以通过修补 <msys2_path>/mingw64/include/c++/9.2.0/bits/fs_path.h
来解决.
在第 666-692 行,定义了 class filesystem_error
.它必须向上移动到第 614 行,正好在 u8path()
的定义之上。 .
我认为这是一个 libstdc++ 错误。我已经举报了here .
class filesystem_error
在 bits/fs_path.h
中多次使用,并且除了有问题的第 636 行外,它的每次使用都在定义之下。
该行包含在 #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
中,所以我猜 Clang 开发人员不会在 Windows 上运行 libstdc++ 兼容性测试。
UPD:这已在 GCC 9.3 中修复。
关于c++ - Clang 拒绝编译 libstdc++ 的 <filesystem> header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57963460/
有没有办法确定我是否可以使用标准 (在所有支持 C++17 的现代 C++ 编译器上可用)或 由较旧的编译器使用。 (例如 g++ 6.3,这是 Debian Stretch 上的当前标准版本) 知
因此,boost::filesystem 允许您在文件所有者拥有的权限、组拥有的权限以及所有用户拥有的权限的意义上访问文件的权限。这很好,但我不想开始检查我是谁,我的组是什么等等——我只想检查我是否可
我不小心使用 rm -rf 删除了错误的文件夹,我尝试过的每个工具都告诉我我没有硬盘或找不到文件系统。 当我输入 df 时,我得到: 已使用的文件系统大小 Avail Use% Mounted on
我是 Java 的新手,正在尝试学习 IO 的概念。我遇到过两个非常相似的 Java 类,FileSystem 和 FileSystems。它们之间有什么区别?什么时候使用一个而不是另一个? 最佳答案
我查了很多关于c++17下文件系统链接的问题,还是无法链接成功。我的main.cpp文件如下。 #include int main(int argc, char** argv) { std:
Boost 库有一个类来处理文件路径:boost::filesystem::path。Boos 也有这个类 boost::filesystem::wpath 每个类都有方法string(), wstr
我正在编写一个利用 std::filesystem 的库(仅供学习)。它在 MSVC 上运行良好,但是默认情况下,Linux 的 LTS 版本就像 Ubuntu 一样附带 GCC 6.x,官方存储库中
请查找随附的代码片段。我正在使用此代码将文件从 hdfs 下载到我的本地文件系统 - Configuration conf = new Configuration(); FileSys
这段代码中std::filesystem::copy()和std::filesystem::copy_file()有什么区别? #include void testing() { const
以下代码旨在去除路径的第一部分,以防它存在: #include std::filesystem::path strip_prefix(std::filesystem::path p) {
在以下两种情况下,是否有理由调用lexically_normal: std::filesystem::path filepath = someFuntionThatGetsAPath(); filep
函数 boost::filesystem::canonical() ( doc of 1.66 , doc of current release ) 提供两个参数(忽略错误代码重载)base。第一个是
boost::filesystem::path使用 &转义路径字符串中的引号,see demo : std::cout 标题。 最佳答案 Boost::Filesystem 相当古老,早于 C++14
考虑以下关于路径分解的断言,其中每个局部变量,例如stem 具有明显的初始化,例如auto stem = path.stem() — assert(root_path == root_name / r
给定以下代码: fs::path p{ "a/b/" }; fs::path q{ "a/b/." }; assert(p == q); [注意定义 q 的字符串末尾的额
由于 C++17 std::filesystem 与 boost::filesystem 非常相似,所以我尝试做与这个问题相同的事情: Escaping some Directories in ite
我找到了这个页面,描述了 c++14 和 c++17 之间的变化: https://isocpp.org/files/papers/p0636r0.html ... 它链接到此页面,该页面描述了建议的
我有一些代码,当我编译它时,出现以下错误,我不知道如何解决。我尝试添加 -L/usr/lib/x86_64-linux-gnu、-lboost_system 和 -lboost_filesystem,
尝试使用 Asset.loadAsync 将 .txt Assets 作为字符串加载到 Expo 中 Asset.loadAsync(module) 解析并提供一个 localUri 但是,FileS
我在 中编码C++ 在 Visual Studio (Windows 10)并收到此错误: #error The header providing std::experimental::filesy
我是一名优秀的程序员,十分优秀!