gpt4 book ai didi

c++ - std::experimental::与ndk/clang一起使用

转载 作者:行者123 更新时间:2023-12-02 10:38:48 27 4
gpt4 key购买 nike

我正在尝试构建使用std::experimental::optional的项目。对于Linux,它可以很好地编译,但是对于android / ndk,编译器会抛出:
error: no member named 'experimental' in namespace 'std'
我正在使用polly工具链android-ndk-r17-api-24-armeabi-v7a-clang-libcxx14set(CMAKE_CXX_STANDARD 14)构建

# Copyright (c) 2015-2018, Ruslan Baratov
# Copyright (c) 2017-2018, Robert Nitsch
# Copyright (c) 2018, David Hirvonen
# All rights reserved.

if(DEFINED POLLY_ANDROID_NDK_R17_API_24_ARMEABI_V7A_CLANG_LIBCXX14_CMAKE_)
return()
else()
set(POLLY_ANDROID_NDK_R17_API_24_ARMEABI_V7A_CLANG_LIBCXX14_CMAKE_ 1)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/utilities/polly_clear_environment_variables.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/utilities/polly_init.cmake")

set(ANDROID_NDK_VERSION "r17")
set(CMAKE_SYSTEM_VERSION "24")
set(CMAKE_ANDROID_ARCH_ABI "armeabi-v7a")
set(CMAKE_ANDROID_ARM_NEON TRUE)
set(CMAKE_ANDROID_ARM_MODE TRUE) # 32-bit ARM
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION "clang")
set(CMAKE_ANDROID_STL_TYPE "c++_static") # LLVM libc++ static

polly_init(
"Android NDK ${ANDROID_NDK_VERSION} / \
API ${CMAKE_SYSTEM_VERSION} / ${CMAKE_ANDROID_ARCH_ABI} / \
Clang / c++14 support / libc++ static"
"Unix Makefiles"
)

include("${CMAKE_CURRENT_LIST_DIR}/utilities/polly_common.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/flags/cxx14.cmake") # before toolchain!

include("${CMAKE_CURRENT_LIST_DIR}/os/android.cmake")

我试图建立一个最小的例子:
#include <experimental/optional>
#include <iostream>

int main() {
std::experimental::optional<int> b = 6;
std::cout << b.value() << std::endl;
return 0;
}

但是使用相同的工具链可以很好地构建。

抱歉,无法在此处发布代码。任何想法可能是什么问题?

最佳答案

更新到NDK r19并仅使用std::optional。在C++ 17中不是实验性的。

关于c++ - std::experimental::与ndk/clang一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56063576/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com