0

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: "
    }

このクラスの位置には、データを使用して 1 秒ごとに実行されるメソッド tick があります。メソッド Print data をクラス pos​​ からポーリングしようとしていますが、なぜそのエラーが発生しましたか?

これはクラスpos.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_

4

3 に答える 3

0

pos.h を作成すると、pos というクラスがないように見え、関数名を呼び出すだけで済みます。

 if(pthread_create(&thread,NULL,Print_data,this)!=0) {
于 2013-06-13T13:39:09.220 に答える
0

1) 改善に役立つコード スニペット/追加情報を提供できます。

2) リンク エラーが発生する場合は、-lpthread ライブラリとリンクしているかどうかを確認します。

于 2013-06-13T13:35:48.570 に答える