2832
- 收藏
- 点赞
- 分享
- 举报
NUC972 交叉编译出错,不支持future?
请问大神,为什么用交叉编译工具编译会报这个错误呢?不是支持c++11的吗?
源码:
// future example
#include // std::cout
#include // std::async, std::future
#include // std::chrono::milliseconds
// a non-optimized way of checking for prime numbers:
bool
is_prime(int x)
{
for (int i = 2; i < x; ++i)
if (x % i == 0)
return false;
return true;
}
int main()
{
// call function asynchronously:
std::future < bool > fut = std::async(is_prime, 444444443);
// do something while waiting for function to set future:
std::cout << "checking, please wait";
std::chrono::milliseconds span(100);
while (fut.wait_for(span) == std::future_status::timeout)
std::cout << '.';
bool x = fut.get(); // retrieve return value
std::cout << "\n444444443 " << (x ? "is" : "is not") << " prime.\n";
return 0;
}
编译选项:arm-linux-g++ future.cpp -lpthread -std=c++11
出错内容:
future.cpp: In function ‘int main()’:
future.cpp:19:26: error: variable ‘std::future fut’ has initializer but incomplete type
std::future < bool > fut = std::async(is_prime, 444444443);
^
future.cpp:19:62: error: invalid use of incomplete type ‘class std::future’
std::future < bool > fut = std::async(is_prime, 444444443);
^
In file included from future.cpp:3:0:
/usr/local/arm_linux_4.8/arm-nuvoton-linux-uclibceabi/include/c++/4.8.4/future:113:11: error: declaration of ‘class std::future’
class future;
^
源码:
// future example
#include
#include
#include
// a non-optimized way of checking for prime numbers:
bool
is_prime(int x)
{
for (int i = 2; i < x; ++i)
if (x % i == 0)
return false;
return true;
}
int main()
{
// call function asynchronously:
std::future < bool > fut = std::async(is_prime, 444444443);
// do something while waiting for function to set future:
std::cout << "checking, please wait";
std::chrono::milliseconds span(100);
while (fut.wait_for(span) == std::future_status::timeout)
std::cout << '.';
bool x = fut.get(); // retrieve return value
std::cout << "\n444444443 " << (x ? "is" : "is not") << " prime.\n";
return 0;
}
编译选项:arm-linux-g++ future.cpp -lpthread -std=c++11
出错内容:
future.cpp: In function ‘int main()’:
future.cpp:19:26: error: variable ‘std::future
std::future < bool > fut = std::async(is_prime, 444444443);
^
future.cpp:19:62: error: invalid use of incomplete type ‘class std::future
std::future < bool > fut = std::async(is_prime, 444444443);
^
In file included from future.cpp:3:0:
/usr/local/arm_linux_4.8/arm-nuvoton-linux-uclibceabi/include/c++/4.8.4/future:113:11: error: declaration of ‘class std::future
class future;
^
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片
相关问答
-
2020-11-13 14:18:01
-
2020-12-02 08:28:20
-
2020-11-12 18:09:59
-
2021-01-05 16:26:38
-
2021-01-07 19:25:12
-
2017-10-30 09:59:24
-
2018-01-20 15:11:19
-
1292017-11-11 20:55:58
-
2018-03-16 12:07:19
-
2018-11-26 21:28:30
-
2018-07-12 14:19:30
-
2018-05-17 12:03:04
-
2017-09-11 20:39:08
-
2017-12-20 00:32:33
-
2017-07-01 13:09:45
-
2018-03-06 15:07:59
-
2021-01-05 16:23:59
-
2020-11-12 18:07:47
-
2019-09-03 10:20:29
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5hisi3516cv610 + gc4336p 夜晚很模糊
-
5AIISP(功能演示,SC4336P为BGGR,强制转RGGB,会导致颜色异常)
-
5rv1106使用luckfox的SDK,设备树和驱动都写好了,结果设备文件没有生成
-
5海思3516cv610中如何进行SD卡升级,根据官方文档操作,烧录进板子时,走的默认uboot,没有执行uboot升级。
-
5G610Q-IPC-38E 夜晚很暗 有什么办法解决吗 已经补光了
-
10转换模型时,SoC版本里没显示hi3516cv610芯片
-
5hisi3516cv610 使用 yolov8n 模型训练 要如何提高 这里识别的是人
-
10有人在海思平台接过SC035HGS吗
-
5关于hi3519dv500,以SD卡虚拟 U 盘操作
-
5ss928 sample_venc代码移植到openEuler24.03上执行报错 [sample_comm_vi_start_dev]-1068: vi set dev attr failed wi
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认

微信扫码分享
QQ好友