c++11 - 不完整类型 'class std::promise 的无效使用' 使用 arm-linux-gnueabi-g++-5 编译时出错
问题描述
使用 arm-linux-gnueabi-g++-5 filename.cpp -std=c++11 为 arm 编译以下代码时出现错误
#include <iostream>
#include <thread>
#include <future>
void initiazer(std::promise<int> * promObj)
{
std::cout<<"Inside Thread"<<std::endl; promObj->set_value(35);
}
int main()
{
std::promise<int> promiseObj;
std::future<int> futureObj = promiseObj.get_future();
std::thread th(initiazer, &promiseObj);
std::cout<<futureObj.get()<<std::endl;
th.join();
return 0;
}
错误 :
test.cpp:在函数'void initiazer(std::promise*)'中:test.cpp:10:55:错误:不完整类型'class std::promise'的无效使用std::cout<<"Inside Thread" <set_value(35); ^ 在 test.cpp:4:0 中包含的文件中:/usr/arm-linux-gnueabi/include/c++/5/future:124:11:注意:“class std::promise”类承诺的声明;^ test.cpp:在函数'int main()'中:test.cpp:15:23:错误:聚合'std::promise promiseObj'类型不完整,无法定义std::promise promiseObj;^ test.cpp:16:22: 错误:变量 'std::future futureObj' 具有初始化程序但类型不完整 std::future futureObj = promiseObj.get_future();
解决方案
推荐阅读
- ios - Xamarin iOS 和 .Net Standard 2.0 依赖服务
- java - Python 和 Java 中的位操作
- python - 带有圆形图像的 Qlabel
- python - 在 tensorflow 中使用 export_savedmodel 的正确方法是什么?
- wordpress - 从包含 WordPress 的目录中删除尾部斜杠
- android - Carles 代理在 Android 中不起作用
- html - 无法以指定宽度居中段落
- php - 使用 xampp 的 magento 版本 2.1.13 错误
- python - 优化 pandas 运行时的过滤功能
- java - 更改现有 PDF 文档的方向(纵向/横向)