根据cppreference,要确定
然而,我的系统定义了
我该如何处理这种情况?是否有一种方法可以检查符号是否已定义?
std::hardware_constructive_interference_size
是否可用,它使用以下示例:#include <new>
#ifdef __cpp_lib_hardware_interference_size
using std::hardware_constructive_interference_size;
using std::hardware_destructive_interference_size;
#else
// 64 bytes on x86-64 │ L1_CACHE_BYTES │ L1_CACHE_SHIFT │ __cacheline_aligned │ ...
constexpr std::size_t hardware_constructive_interference_size
= 2 * sizeof(std::max_align_t);
constexpr std::size_t hardware_destructive_interference_size
= 2 * sizeof(std::max_align_t);
#endif
然而,我的系统定义了
__cpp_lib_hardware_interference_size
但没有符号std::hardware_constructive_interference_size
。我该如何处理这种情况?是否有一种方法可以检查符号是否已定义?
- Apple clang版本12.0.0(clang-1200.0.32.29)
目标:x86_64-apple-darwin19.6.0
线程模型:posix
InstalledDir:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin - macOS Catalina 10.15.7(MacBook Pro 2019)
CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
project(untitled4)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
if (UNIX AND NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
add_executable(untitled4 main.cpp)
__cpp_lib_hardware_interference_size
,它的值是多少?它是否为>= 201703L
?在阅读一个旧的LLVM邮件线程时,我注意到他们非常不愿意将其添加到他们的库中,并考虑向标准委员会编写缺陷报告。 - Ted Lyngmoclang++-12
(在Linux上)没有定义那个宏。 - Ted Lyngmo