From 402e432c4b200549563d5363f4a1454d0692cb5b Mon Sep 17 00:00:00 2001 From: David Boehme Date: Tue, 22 Oct 2024 01:20:28 +0200 Subject: [PATCH] Don't use std::filesystem in libstdc++ 8 (#608) --- src/common/OutputStream.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/common/OutputStream.cpp b/src/common/OutputStream.cpp index 332d8c44..30c7b5ed 100644 --- a/src/common/OutputStream.cpp +++ b/src/common/OutputStream.cpp @@ -13,8 +13,14 @@ #include #include -// MSVC has a low value of __cplusplus even though it support C++17 -#if defined(_WIN32) || (__cplusplus >= 201703L) +// (1) MSVC has a low value of __cplusplus even though it support C++17. +// (2) std::filesystem support in libstdc++ prior to gcc 9 requires linking +// an extra libstdc++-fs library. Let's not bother with this. +#if defined(_WIN32) || (__cplusplus >= 201703L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 9)) +#define CALI_OSTREAM_USE_STD_FILESYSTEM +#endif + +#ifdef CALI_OSTREAM_USE_STD_FILESYSTEM #include #else #include @@ -26,7 +32,7 @@ using namespace cali; namespace { -#if defined(_WIN32) || (__cplusplus >= 201703L) +#ifdef CALI_OSTREAM_USE_STD_FILESYSTEM bool check_and_create_directory(const std::filesystem::path& filepath) { try { @@ -90,7 +96,7 @@ struct OutputStream::OutputStreamImpl { bool is_initialized; std::mutex init_mutex; -#if defined(_WIN32) || (__cplusplus >= 201703L) +#ifdef CALI_OSTREAM_USE_STD_FILESYSTEM std::filesystem::path filename; #else std::string filename;