为什么这个tbb程序无法编译
Why this tbb program cannot compile?
我在 centos 目录/home/is_admin/tbb40_233oss/中安装了线程构建块(http://threadingbuildingblocks.org/ver.php?fid=174)
这是我的代码:
#include "tbb/concurrent_queue.h"
#include <iostream>
using namespace std;
using namespace tbb;
int main() {
concurrent_queue<int> queue;
for( int i=0; i<10; ++i )
queue.push(i);
for( concurrent_queue<int>::const_iterator i(queue.begin());
i!=queue.end(); ++i )
cout << *i << " ";
cout << endl;
return 0;
}
我使用以下命令编译代码:
g++ test_concurrent_queue.cpp -I/home/is_admin/tbb40_233od/linux_intel64_gcc_cc4.1.2_libc2.5_kernel2.6.18_release -ltbb -o tcq
但它给出了这个错误:
class tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> > has no member named begin
class tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> > has no member named end
我不知道为什么?有人有 tbb 经验可以帮助我吗?
编辑:
您使用的文档已过时,不再适用于 concurrent_queue
。我的其余答案仍然成立。
因为concurrent_queue
没有begin
或end
方法:http://threadingbuildingblocks.org/files/documentation/a00134.html
有一个unsafe_begin
和一个unsafe_end
方法,以这种方式命名,因为仅当您的队列未被多个线程使用时才应使用它们(也就是说,在多线程环境中使用它们不安全)。
运行队列的一般方法是弹出元素,直到它为空:
int i;
while(queue.try_pop(i)) // as long as you can pop, pop.
cout << i << " ";
相关文章:
- 如何从测试脚本中运行WAF编译C++程序?
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 在Yocto上本地构建和编译C / C++程序
- 我无法在代码块中编译c ++程序。它给了我错误
- 在 turbo c++ 中使用 TCC 从 cmd 编译C++程序
- 如何在Linux中编译C 程序以生成Windows可执行文件
- 在Python中编译C 程序时,请尝试捕获OS错误
- 在Windows命令提示符中使用G 编译C 程序
- 如何使用HDF5源代码编译c程序
- 如何在Mac终端中编译C ++程序
- 设置 VS 代码以编译C++程序
- 无法在 Ubuntu 上编译 c++ 程序
- 无法使用 libcurl 库编译 c++ 程序
- 编译C 程序,该程序将SFML与MINGW一起到端口,从Linux到Windows
- 编译C 程序时具有逻辑错误,该程序应将任意大的数字表示为字符串
- 如何在 Windows 命令提示符下使用 Dev C++ 编译器编译 c++ 程序
- 在cygwin中使用mingw编译器编译c ++程序时缺少dll。
- 无法在Windows上编写的Linux上编译C程序
- 架构的未定义符号x86_64惠姆使用G 编译C 程序
- 指定netbeans用来编译C++程序的完整编译命令