Creating threads in C vs C++

J

john

Hi,

I'm writing a multithreaded application in C++. I tried to do like C
posix threads and pass an object method. But I got a compilation error:

'argument of type 'void*(myclass::)(void *)' does not match 'void *
(*)(void *)'

I've done lots of multithreaded work in C. But this my first time doing
it in C++. How do I create a thread in C++?

Cheers

John
 
A

AnonMail2005

Hi,

I'm writing a multithreaded application in C++. I tried to do like C
posix threads and pass an object method. But I got a compilation error:

   'argument of type 'void*(myclass::)(void *)' does not match 'void *
(*)(void *)'

I've done lots of multithreaded work in C. But this my first time doing
it in C++. How do I create a thread in C++?

Cheers

John

It looks like your attempting to use a class member function pointer
where a just a plain function pointer is expected. You will have to
make the function either a class static function a free function
(outside of any class).

HTH
 
I

Ian Collins

It looks like your attempting to use a class member function pointer
where a just a plain function pointer is expected. You will have to
make the function either a class static function a free function
(outside of any class).

A static member function isn't strictly correct, the thread function
should be a C linkage (extern "C") free function. This can still be a
friend of the class.
 
R

Rui Maciel

john said:
Hi,

I'm writing a multithreaded application in C++.
<snip />

I believe that, for that topic, you will get better answers in a newsgroup
dedicated to parallel programming, such as comp.programming.threads.

Other than that, in order to help others help you, it would be better if you
provided an example of the offending code.


Rui Maciel
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top