3597
- 收藏
- 点赞
- 分享
- 举报
Hi3519使用c++ future 模板问题
1,源码
#include
#include
#include
#include
#include
#include
std::uint32_t add(std::uint32_t a, std::uint32_t b)
{
std::cout << "thread id = " << std::this_thread::get_id() << ", a = " << a << ", b = " << b << std::endl;
if(std::numeric_limits::max() - a < b) {
throw std::overflow_error("overflow_error");
}
return a + b;
}
int main()
{
// 使用std::async启动异步操作并返回std::future对象
std::future f1 = std::async(std::launch::async, add, 1ul, 2ul);
// 通过std::future::get等待异步操作完成并取得返回值
std::uint32_t sum1 = f1.get();
std::cout << "thread id = " << std::this_thread::get_id() << ", sum1 = " << sum1 << std::endl;
// 4000000000ul + 4000000000ul会抛出异常,异常会被延迟到std::future::get或std::future::wait时抛出
std::future f2 = std::async(std::launch::async, add, 4000000000ul, 4000000000ul);
try {
std::uint32_t sum2 = f2.get();
std::cout << "thread id = " << std::this_thread::get_id() << ", sum2 = " << sum2 << std::endl;
}
catch(const std::overflow_error& e) {
std::cout << "thread id = " << std::this_thread::get_id() << ", e.what() = " << e.what() << std::endl;
}
}
2,Ubuntu 上编译 g++ -o testfure2 testfuture2.cpp -std=c++11 -lpthread 通过,运行正常;
3,hisi3519 使用arm-hisiv600-linux-g++ -o testfure2 testfuture2.cpp -std=c++11 -lpthread
testfuture2.cpp: In function ‘int main()’:
testfuture2.cpp:20:32: error: variable ‘std::future f1’ has initializer but incomplete type
std::future f1 = std::async(std::launch::async, add, 1ul, 2ul);
^
testfuture2.cpp:20:81: error: invalid use of incomplete type ‘class std::future’
std::future f1 = std::async(std::launch::async, add, 1ul, 2ul);
^
In file included from testfuture2.cpp:2:0:
/opt/hisi-linux/x86-arm/arm-hisiv600-linux/arm-hisiv600-linux-gnueabi/include/c++/4.9.4/future:114:11: error: declaration of ‘class std::future’
class future;
^
testfuture2.cpp:25:32: error: variable ‘std::future f2’ has initializer but incomplete type
std::future f2 = std::async(std::launch::async, add, 4000000000ul, 4000000000ul);
^
testfuture2.cpp:25:99: error: invalid use of incomplete type ‘class std::future’
std::future f2 = std::async(std::launch::async, add, 4000000000ul, 4000000000ul);
^
In file included from testfuture2.cpp:2:0:
/opt/hisi-linux/x86-arm/arm-hisiv600-linux/arm-hisiv600-linux-gnueabi/include/c++/4.9.4/future:114:11: error: declaration of ‘class std::future’
class future;
^
出现以上错误!?
大侠帮忙看看?跪等!
#include
#include
#include
#include
#include
#include
std::uint32_t add(std::uint32_t a, std::uint32_t b)
{
std::cout << "thread id = " << std::this_thread::get_id() << ", a = " << a << ", b = " << b << std::endl;
if(std::numeric_limits
throw std::overflow_error("overflow_error");
}
return a + b;
}
int main()
{
// 使用std::async启动异步操作并返回std::future对象
std::future
// 通过std::future::get等待异步操作完成并取得返回值
std::uint32_t sum1 = f1.get();
std::cout << "thread id = " << std::this_thread::get_id() << ", sum1 = " << sum1 << std::endl;
// 4000000000ul + 4000000000ul会抛出异常,异常会被延迟到std::future::get或std::future::wait时抛出
std::future
try {
std::uint32_t sum2 = f2.get();
std::cout << "thread id = " << std::this_thread::get_id() << ", sum2 = " << sum2 << std::endl;
}
catch(const std::overflow_error& e) {
std::cout << "thread id = " << std::this_thread::get_id() << ", e.what() = " << e.what() << std::endl;
}
}
2,Ubuntu 上编译 g++ -o testfure2 testfuture2.cpp -std=c++11 -lpthread 通过,运行正常;
3,hisi3519 使用arm-hisiv600-linux-g++ -o testfure2 testfuture2.cpp -std=c++11 -lpthread
testfuture2.cpp: In function ‘int main()’:
testfuture2.cpp:20:32: error: variable ‘std::future
std::future
^
testfuture2.cpp:20:81: error: invalid use of incomplete type ‘class std::future
std::future
^
In file included from testfuture2.cpp:2:0:
/opt/hisi-linux/x86-arm/arm-hisiv600-linux/arm-hisiv600-linux-gnueabi/include/c++/4.9.4/future:114:11: error: declaration of ‘class std::future
class future;
^
testfuture2.cpp:25:32: error: variable ‘std::future
std::future
^
testfuture2.cpp:25:99: error: invalid use of incomplete type ‘class std::future
std::future
^
In file included from testfuture2.cpp:2:0:
/opt/hisi-linux/x86-arm/arm-hisiv600-linux/arm-hisiv600-linux-gnueabi/include/c++/4.9.4/future:114:11: error: declaration of ‘class std::future
class future;
^
出现以上错误!?
大侠帮忙看看?跪等!
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2018-01-19 10:49:05
-
2017-07-24 23:04:14
-
2017-03-20 11:06:40
-
2018-04-11 14:24:10
-
2017-07-19 18:48:11
-
2020-04-02 09:26:31
-
2019-01-04 11:04:54
-
2017-07-11 17:38:56
-
2017-09-19 19:33:32
-
2018-10-13 15:00:33
-
02019-05-21 10:06:45
-
22017-10-12 19:25:44
-
2019-03-16 11:51:33
-
2017-11-22 14:39:31
-
2017-03-31 09:45:17
-
2019-04-02 00:06:46
-
2019-03-19 16:17:31
-
2017-02-24 16:48:01
-
2017-04-24 13:35:08
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
-
10求HI3519DV500_SDK_V2.0.1.1
-
5有偿求HI3516DV500 + OV5647驱动
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认