我正在尝试构建使用std::experimental::optional
. 对于 Linux,它编译得很好,但对于 android/ndk,编译器会抛出:
error: no member named 'experimental' in namespace 'std'
我正在使用polly工具链android-ndk-r17-api-24-armeabi-v7a-clang-libcxx14
和set(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;
}
但它使用相同的工具链构建得很好。
我很抱歉,我不能在这里发布我的代码。任何想法可能是什么问题?