pthread_create for class ?

V

vertigo

Hello
I have class Node and function:
void Node::Start(void){
pthread_create(&ServerLoopThread,NULL,&Node::StartServerLoop,NULL);
}

void Node::StartServerLoop(void){
...
}

and durring compilation i receive error:
Node.c: In member function `void Node::Start()':
Node.c:21: error: cannot convert `void (Node::*)()' to `void*(*)(void*)'
for
argument `3' to `int pthread_create(pthread_t*, const pthread_attr_t*,
void*(*)(void*), void*)'
make: *** [Node.o] Error 1

when i changed to:

pthread_create(&ServerLoopThread,NULL,(void*(*)(void*))&Node::StartServerLoop,NULL);
i receive error:
Node.c: In member function `void Node::Start()':
Node.c:20: error: converting from `void (Node::*)()' to `void*(*)(void*)'
make: *** [Node.o] Error 1

Why ?
How can i correct it ?

Thanx
Michal
 
P

Paul Lutus

vertigo said:
Hello
I have class Node and function:
void Node::Start(void){
pthread_create(&ServerLoopThread,NULL,&Node::StartServerLoop,NULL);
}

void Node::StartServerLoop(void){


This is not Java code. Did you just choose a newsgroup at random?
...
}

and durring compilation i receive error:
Node.c: In member function `void Node::Start()':
Node.c:21: error: cannot convert `void (Node::*)()' to `void*(*)(void*)'
for
argument `3' to `int pthread_create(pthread_t*, const pthread_attr_t*,
void*(*)(void*), void*)'
make: *** [Node.o] Error 1

when i changed to:

pthread_create(&ServerLoopThread,NULL,(void*(* (void*))&Node::StartServerLoop,NULL);
i receive error:
Node.c: In member function `void Node::Start()':
Node.c:20: error: converting from `void (Node::*)()' to `void*(*)(void*)'
make: *** [Node.o] Error 1

Why ?
How can i correct it ?

Well, you can start by posting to an appropriate newsgroup. Your code looks
like C++. I think if you cannot identify which language you are coding in,
it's going to be a long haul between this moment and a working program.
 
Z

zoopy

I think if you cannot identify which language you are coding in,
it's going to be a long haul between this moment and a working program.

Yes, another nice comment. Keep them coming Paul, I like them.
 
T

Tor Iver Wilhelmsen

zoopy said:
Yes, another nice comment. Keep them coming Paul, I like them.

Stalking someone on Usenet is soo 1990s. Take up stamp collecting or
something, already.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top