pthread_create() "类未在作用域中声明?

pthread_create() "class not declared in the scope?

本文关键字:作用域 声明 create pthread      更新时间:2023-10-16

我有一个类叫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) {