From ced00f5a2e2b8623d1ee6a9afef80fc5df08d509 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 8 Aug 2022 17:16:36 +0100 Subject: fs: work around u8path deprecated-declaration warnings with libc++ When building in c++20 mode using libc++, the following warning is emitted: ```bash ./fs.h:72:29: warning: 'u8path' is deprecated [-Wdeprecated-declarations] return std::filesystem::u8path(utf8_str); ^ /usr/lib/llvm-14/bin/../include/c++/v1/__filesystem/u8path.h:72:27: note: 'u8path' has been explicitly marked deprecated here _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T ^ /usr/lib/llvm-14/bin/../include/c++/v1/__config:1042:43: note: expanded from macro '_LIBCPP_DEPRECATED_WITH_CHAR8_T' ^ /usr/lib/llvm-14/bin/../include/c++/v1/__config:1007:48: note: expanded from macro '_LIBCPP_DEPRECATED' ^ 1 warning generated. ``` as u8path is deprecated starting with c++20. Fixes: #24682. Co-authored-by: MacroFake Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> --- src/fs.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/fs.h') diff --git a/src/fs.h b/src/fs.h index e8b34319bb..ac58c4a2ba 100644 --- a/src/fs.h +++ b/src/fs.h @@ -69,7 +69,11 @@ public: static inline path u8path(const std::string& utf8_str) { +#if __cplusplus < 202002L return std::filesystem::u8path(utf8_str); +#else + return std::filesystem::path(std::u8string{utf8_str.begin(), utf8_str.end()}); +#endif } // Disallow implicit std::string conversion for absolute to avoid -- cgit v1.2.3