Skip to content

Commit

Permalink
Include <filesystem> only if FMT_CPP_LIB_FILESYSTEM is set (#4258)
Browse files Browse the repository at this point in the history
This change results out of necessity since the Nintendo Switch console
SDK does not support `std::filesystem`. The SDK still provides the
`<filesystem>` header, but with an `#error` directive, effectively
breaking any build that includes `<filesystem>`

Because `<filesystem>` is present, `FMT_HAS_INCLUDE` is insufficient
here. With this change and `FMT_CPP_LIB_FILESYSTEM` in place, one can
define `FMT_CPP_LIB_FILESYSTEM=0` to work around this issue.

This assumes that `<filesystem>` can be included (without warnings) if
`FMT_CPP_LIB_FILESYSTEM` is set. If this is not the case, fmt would be
broken even before this change as `std::filesystem::path` is used
without the accompanying header.
  • Loading branch information
W4RH4WK authored Dec 7, 2024
1 parent 47a66c5 commit 9600fee
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

// Check FMT_CPLUSPLUS to suppress a bogus warning in MSVC.
# if FMT_CPLUSPLUS >= 201703L
# if FMT_HAS_INCLUDE(<filesystem>)
# include <filesystem>
# endif
# if FMT_HAS_INCLUDE(<variant>)
# include <variant>
# endif
Expand Down Expand Up @@ -79,6 +76,7 @@
#endif

#if FMT_CPP_LIB_FILESYSTEM
# include <filesystem>
FMT_BEGIN_NAMESPACE

namespace detail {
Expand Down

0 comments on commit 9600fee

Please sign in to comment.