如何使用原子头C++

Ath*_*lha 0 c++ multithreading redhat atomic

我正在尝试编译一个包含原子 headerr 的 C++ 文件,

我收到此错误:

#error <atomic> is not supported on this single threaded system
Run Code Online (Sandbox Code Playgroud)

我使用交叉编译的 clang。我在 redHat 6.9 上运行

Typ*_*eIA 5

此错误意味着目标系统的libcxx 的配置没有线程支持。的文档libcxx 概述了它的线程支持。

_LIBCPP_HAS_NO_THREADS

该宏是在构建 libc++ 时定义的,没有线程支持。它不应该由用户手动定义。

您收到的错误意味着已_LIBCPP_HAS_NO_THREADS定义。具体来说,从atomic标题:

#ifdef _LIBCPP_HAS_NO_THREADS
#error <atomic> is not supported on this single threaded system
#endif
Run Code Online (Sandbox Code Playgroud)

您需要了解是否可以为您的目标平台构建/配置 libcxx,并支持 libcxx 文档中所述的线程支持。