pthread_create() "类未在作用域中声明?
pthread_create() "class not declared in the scope?
我有一个类叫pos…我试图从这个类轮询一个方法。我使用pthread_create(pthread_t thread, pos::Pirnt_data,this);
我得到一个错误,pos没有在作用域中声明…我包含了pos的h文件,但是我不明白。我想我用错格式了,谁能帮我一下
#include "position.h"
#include "pthread.h"
#include "pos.h"
void position::tick(schedflags_t flags)
{
if(pthread_create(&thread,NULL,pos::Print_data,this)!=0) {
stringstream bad;
bad << "OPIMex: Could not create listener thread: "
}
这个类位置有一个方法tick,它每1秒运行一次数据。我正试图轮询一个方法打印数据从类pos,但它给了我这个错误,任何想法为什么?
这是类post .h
#ifndef POS_H_
#define POS_H_
#include <math.h>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <gps.h>
#include <string.h>
#include <pthread.h>
#include <string>
#include <vector>
#include <strings.h>
#include <math.h>
using namespace std;
namespace herpderp {
namespace modules {
int UBX_step =0;
long data;
int UBX_class;
int UBX_id=0;
int UBX_payload_length_hi;
int UBX_payload_length_lo;
int UBX_payload_counter =0;
int ck_a;
int ck_b;
int GPS_timer;
int fd;
unsigned int UBX_buffer[35];
int payload_data;
long lat=0;
long lon=0;
long alt_MSL=0;
long iTOW=0;
long alt=0;
unsigned long LastMS;
int UBX_Read;
vector <float> v;
fstream myfile;
int Open_port(void);
int read_tofile();
long join_4_bytes( unsigned int Buffer[]);
void parse_ubx_gps(void);
void checksum(char ubx_data);
void Print_data();
int push_data_into_vector();
int decode_gps();
int Configure_gps();
int test();
int Close_NEMA();
int Open_UBX();
}
}# endif//POS_H_
pthread_kill
不在pthread.
上。它在signal.h
#include <signal.h>
1)你可以提供一些代码片段/附加信息来帮助你更好。
2)如果你得到链接错误,检查你是否与-lpthread库链接。
from post .h似乎没有类称为pos,你只需要调用函数名:
if(pthread_create(&thread,NULL,Print_data,this)!=0) {
相关文章:
- 未在作用域中声明unordered_map
- 未在此作用域OpenCV3.4中声明cvSaveImage
- 未在此作用域中声明的函数和变量 (C++)
- 函数未在作用域中声明 / 如何结合使用 header.h、header.cpp 和 main.cpp?
- 重载时未在 C++ 的作用域错误中声明
- 在 C++ 中使用 "transform" 会给出一个错误,指出这未在作用域中声明
- Tictactoe 游戏变量未在作用域中声明
- 当变量在多个函数作用域中使用时,我应该在类 private 中声明该变量吗?
- 如何在C++中嵌套词法作用域可访问的作用域中声明静态信息?
- gets()未在作用域中声明
- 在C++14中,在哪个作用域中声明了重新声明枚举的非范围枚举器
- C++11 外部作用域变量声明为 auto
- 未在此作用域中声明类 (c++)
- 如何声明在函数作用域中定义的结构
- 未在此作用域中声明函数,即使存在头文件也是如此
- 变量声明中结构的作用域解析是什么意思
- 在C++中,在给定的相同作用域内声明相同的变量名
- 我可以使用相同的名称为周围作用域中的类型声明成员类型别名吗
- 类未在作用域中声明,但已声明该类
- 使用新的外部函数作用域声明和初始化变量