std-filesystem

How to avoid std::filesystem linker errors with Qt?

你离开我真会死。 提交于 2020-06-28 03:07:35
问题 I would like to use the std::filesystem with Qt 5.12.0 with the g++ version Ubuntu 8.2.0-7ubuntu1, but getting linker errors: g++ -lstdc++fs -Wl,-rpath,/home/user/Qt/5.12.0/gcc_64/lib -o qf_filesystem_test main.o -L/home/user/Qt/5.12.0/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread /usr/bin/ld: main.o: in function `std::filesystem::exists(std::filesystem::__cxx11::path const&)': /usr/include/c++/8/bits/fs_ops.h:121: undefined reference to `std::filesystem::status(std::filesystem::_

How to convert `std::filesystem::file_time_type` to a string using GCC 9

不羁岁月 提交于 2020-06-10 19:46:51
问题 I'm trying to format the modification time of a file as a string (UTC). The following code compiles with GCC 8, but not GCC 9. #include <chrono> #include <filesystem> #include <iomanip> #include <iostream> #include <sstream> namespace fs = std::filesystem; int main() { fs::file_time_type file_time = fs::last_write_time(__FILE__); std::time_t tt = decltype(file_time)::clock::to_time_t(file_time); std::tm *gmt = std::gmtime(&tt); std::stringstream buffer; buffer << std::put_time(gmt, "%A, %d %B

How to convert `std::filesystem::file_time_type` to a string using GCC 9

坚强是说给别人听的谎言 提交于 2020-06-10 19:45:52
问题 I'm trying to format the modification time of a file as a string (UTC). The following code compiles with GCC 8, but not GCC 9. #include <chrono> #include <filesystem> #include <iomanip> #include <iostream> #include <sstream> namespace fs = std::filesystem; int main() { fs::file_time_type file_time = fs::last_write_time(__FILE__); std::time_t tt = decltype(file_time)::clock::to_time_t(file_time); std::tm *gmt = std::gmtime(&tt); std::stringstream buffer; buffer << std::put_time(gmt, "%A, %d %B

Compile error when std::filesystem header file is added to my program

给你一囗甜甜゛ 提交于 2020-01-02 09:57:16
问题 I am trying to compile a simple C++ program with std::filesytem header file included! #include <iostream> #include <filesystem> int main() { std::cout << "Hello, World!" << std::endl; return 0; } On compiling I get the following error In file included from C:/PROGRA~1/MINGW-~1/X86_64~2.0-W/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/filesystem:37, from C:\Users\{User}\CLionProjects\untitled3\main.cpp:2: C:/PROGRA~1/MINGW-~1/X86_64~2.0-W/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0

Compile error when std::filesystem header file is added to my program

允我心安 提交于 2020-01-02 09:57:12
问题 I am trying to compile a simple C++ program with std::filesytem header file included! #include <iostream> #include <filesystem> int main() { std::cout << "Hello, World!" << std::endl; return 0; } On compiling I get the following error In file included from C:/PROGRA~1/MINGW-~1/X86_64~2.0-W/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/filesystem:37, from C:\Users\{User}\CLionProjects\untitled3\main.cpp:2: C:/PROGRA~1/MINGW-~1/X86_64~2.0-W/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0

[LLVM-9 clang-9 OSX]: std::filesystem::path unrecognized

99封情书 提交于 2019-12-24 07:53:12
问题 Hello after upgrading on OSX Mojave to the version LLVM-9 using brew upgrade llvm I got the following error: In file included from /Users/roman/CLionProjects/Milerius/antara-gaming-sfml-template/cmake-build-debug/_deps/antara-gaming-sdk-src/modules/core/antara/gaming/core/real.path.cpp:17: /Users/roman/CLionProjects/Milerius/antara-gaming-sfml-template/cmake-build-debug/_deps/antara-gaming-sdk-src/modules/core/antara/gaming/core/real.path.hpp:23:22: fatal error: 'path' is unavailable:

VS2017: E0135 namespace “std” has no member “filesystem”

℡╲_俬逩灬. 提交于 2019-12-21 06:49:49
问题 In order to use: std::filesystem from the C++17 library, my project was migrated from vs2015 to vs2017. My project compiles and runs without error, the lib is included without error, but when trying to use std::filesystem I get the following: It seems the library is not being included but cant see why not? Edit: Microsoft Visual Studio Enterprise 2017 VisualStudio.15.Release/15.7.3+27703.2026 Visual C++ 2017 00369-90000-00000-AA466 Microsoft Visual C++ 2017 回答1: A couple of options to

Passing std::filesystem::path to a function segfaults

岁酱吖の 提交于 2019-12-17 20:14:37
问题 When I attempt to use std::filesystem::path as a function argument, it segfaults on my machine. Here is a minimal example: #include <filesystem> void thing(const std::filesystem::path& p) { return; } int main() { thing("test"); return 0; } This snippet results in the following backtrace from gdb: #0 0x0000563a5a3814b3 in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x23, __in_chrg=<optimized out>) at /usr/include/c++

Implicit conversion between std::filesystem::path and std::string, should it happen?

倖福魔咒の 提交于 2019-12-12 17:21:50
问题 The cppreference page for std::filesystem::path states: Paths are implicitly convertible to and from std::basic_strings , which makes it possible to use them with over files APIs, e.g. as an argument to std::ifstream::open Now the conversion to a std::filesystem::path is easy to see as it has a non-explicit constructor that takes std::string types. What I can't seem to find, though, is a way to go to a std::string implicitly. There is a string function, but it is std::string string() const; ,

Passing std::filesystem::path to a function segfaults

一曲冷凌霜 提交于 2019-11-28 12:48:00
When I attempt to use std::filesystem::path as a function argument, it segfaults on my machine. Here is a minimal example: #include <filesystem> void thing(const std::filesystem::path& p) { return; } int main() { thing("test"); return 0; } This snippet results in the following backtrace from gdb: #0 0x0000563a5a3814b3 in std::vector<std::filesystem::__cxx11::path::_Cmpt, std::allocator<std::filesystem::__cxx11::path::_Cmpt> >::~vector (this=0x23, __in_chrg=<optimized out>) at /usr/include/c++/8/bits/stl_vector.h:567 #1 0x0000563a5a38132c in std::filesystem::__cxx11::path::~path (this=0x3, __in