gpt4 book ai didi

c++ - 为什么我不能使用

转载 作者:太空宇宙 更新时间:2023-11-04 14:29:20 25 4
gpt4 key购买 nike

我想在我的 cpp 多线程代码中使用 std::experimental::barrier。但即使我写这样的代码:

#include <iostream>
#include <thread>
#include <experimental/barrier>

int main () {

return 0;
}

编译器抛出一个错误说:

experimental/barrier: No such file or directory
#include <experimental/barrier>
^`

我在我的 Ubuntu 机器上使用 g++ 版本 6.3.0。这是我正在尝试的命令:

g++ -pthread -std=c++11 top.cpp -o top_new

最佳答案

目前这个库还不可用。

也许这会有用:The GNU C++ Library Manual -> Part III. Extensions -> 30. Concurrency

The file <ext/concurrence.h> contains all the higher-level constructs for playing with threads. In contrast to the atomics layer, the concurrence layer consists largely of types. All types are defined within namespace __gnu_cxx.

...

In addition, there are two macros

_GLIBCXX_READ_MEM_BARRIER

_GLIBCXX_WRITE_MEM_BARRIER

Which expand to the appropriate write and read barrier required by the host hardware and operating system.

关于c++ - 为什么我不能使用 <experimental/barrier>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48714303/

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