D
Damon
Hi,
I have modified a class and tried to compile but I keep getting
errors. Can someone advise me what I'm doing wrong here? Thanks alot.
-----------------error message--------------
g++ -g -Wall -O -finline-functions -I. -I../lib -c -o eve.o eve.cc
In file included from realms/world.h:9,
from eve.cc:8:
.../lib/my_thread.h: In member function `int mylib::my_thread::Stop()':
.../lib/my_thread.h:54: invalid conversion from `pthread_t*' to `long
unsigned
int'
make: *** [eve.o] Error 1
-----------------my_thread.h----------------------
#ifndef MY_THREAD_H
#define MY_THREAD_H
#include "pthread.h"
#include <iostream>
/*
* This code was contributed by Ryan Teixeira ([email protected])
* Thanks for making this code available, dude!
* Some modifications made by me, of course.
*/
namespace mylib {
class my_thread
{
private:
pthread_t ThreadId_;
void * Arg_;
protected:
my_thread() {}
int Run(void * arg) {
Setup();
Execute( arg );
return 0;
}
static void * EntryPoint(void* pthis) {
my_thread * pt = (my_thread*)pthis;
pt->Run( pt->Arg() );
return (void*)NULL;
}
virtual void Setup() {}
virtual void Execute(void* obj) {}
void * Arg() const { return Arg_; }
void Arg(void* a){ Arg_ = a; }
public:
virtual ~my_thread() {}
int Start(void * arg) {
Arg(arg); // store user data
return pthread_create( &ThreadId_,
NULL,
my_thread::EntryPoint,
this );
}
int Stop() {
return pthread_join( &ThreadId_, NULL ); //problem line
here.
}
};
};
#endif
I have modified a class and tried to compile but I keep getting
errors. Can someone advise me what I'm doing wrong here? Thanks alot.
-----------------error message--------------
g++ -g -Wall -O -finline-functions -I. -I../lib -c -o eve.o eve.cc
In file included from realms/world.h:9,
from eve.cc:8:
.../lib/my_thread.h: In member function `int mylib::my_thread::Stop()':
.../lib/my_thread.h:54: invalid conversion from `pthread_t*' to `long
unsigned
int'
make: *** [eve.o] Error 1
-----------------my_thread.h----------------------
#ifndef MY_THREAD_H
#define MY_THREAD_H
#include "pthread.h"
#include <iostream>
/*
* This code was contributed by Ryan Teixeira ([email protected])
* Thanks for making this code available, dude!
* Some modifications made by me, of course.
*/
namespace mylib {
class my_thread
{
private:
pthread_t ThreadId_;
void * Arg_;
protected:
my_thread() {}
int Run(void * arg) {
Setup();
Execute( arg );
return 0;
}
static void * EntryPoint(void* pthis) {
my_thread * pt = (my_thread*)pthis;
pt->Run( pt->Arg() );
return (void*)NULL;
}
virtual void Setup() {}
virtual void Execute(void* obj) {}
void * Arg() const { return Arg_; }
void Arg(void* a){ Arg_ = a; }
public:
virtual ~my_thread() {}
int Start(void * arg) {
Arg(arg); // store user data
return pthread_create( &ThreadId_,
NULL,
my_thread::EntryPoint,
this );
}
int Stop() {
return pthread_join( &ThreadId_, NULL ); //problem line
here.
}
};
};
#endif