c++ - [LLVM-9 clang-9 OSX]: std::filesystem::path 无法识别

标签 c++ c++17 clang++ libc++ std-filesystem

在 OSX Mojave 上使用 brew upgrade llvm 升级到版本 LLVM-9 后你好

我收到以下错误:

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: introduced in macOS 10.15
    std::filesystem::path binary_real_path() noexcept;
                     ^
/usr/local/opt/llvm/bin/../include/c++/v1/filesystem:738:24: note: 'path' has been explicitly marked unavailable here

我的代码:

#include <filesystem>

namespace antara::gaming::core
{
    std::filesystem::path binary_real_path() noexcept;
    std::filesystem::path assets_real_path() noexcept;
}

这正常吗?

最佳答案

其中一种解决方案是使用:-mmacosx-version-min=10.15 编译器标志

在 CMake 中:

add_library(antara_cross_filesystem INTERFACE)
add_library(antara::cross_filesystem ALIAS antara_cross_filesystem)

target_link_libraries(antara_cross_filesystem INTERFACE
        $<$<AND:$<PLATFORM_ID:Linux>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>
        $<$<AND:$<PLATFORM_ID:Darwin>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:c++fs>)
target_compile_options(antara_cross_filesystem INTERFACE
        $<$<AND:$<PLATFORM_ID:Darwin>,$<VERSION_GREATER:$<CXX_COMPILER_VERSION>,8.0>>:-mmacosx-version-min=10.15>)

关于c++ - [LLVM-9 clang-9 OSX]: std::filesystem::path 无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58131130/

相关文章:

c++ - 查找特定函数可以访问的代码

c++ - 从另一个可变参数模板制作可变参数模板

c++ - 防止大型结构之间不必要的复制

c++ - 安全地迭代 std::vector 而项目可能被删除

c++ - 如何禁用隐式 lamba 变量捕获?

C++:将 constexpr lambda 初始化为 constexpr/非 constexpr 变量

c++ - Rextester语言编译C++问题

c++ - 在 Code::blocks 上设置 CLANG 3.4

c++ - 错误 : use of overloaded operator '[]' is ambiguous while building for i386

c++ - CUDA 流破坏和 CudaDeviceReset