Thanks both of you Pieter and Mikko,
Oh yes, this code is not the best one I tried:
threads[i] = zmq_threadstart (&client_task, (void*) args);
threads[i] = zmq_threadstart (&client_task, reinterpret_cast<void*>
(args));
Finally, in an other try, I did let client_task (void **) :-[
Le 22/10/2013 18:35, Pieter Hintjens a écrit :
You have to cast the args to (void *) when calling zmq_threadstart,
and cast the void * argument back to void ** in the child thread.
On Tue, Oct 22, 2013 at 6:29 PM, Laurent Alebarde <[email protected]> wrote:
Hi Devs,
I am trying to use zmq_threadstart. My first test passing ctx as args works,
but I need now to pass two arguments. So I tried many ways and all the time
it ends with a compilor insult :
error: invalid conversion from 'void (*)(void**)' to 'void (*)(void*)'
[-fpermissive]
In file included from ../tests/testutil.hpp:24:0,
from ../tests/test_concurrency_parano.cpp:20:
../tests/../include/zmq_utils.h:94:18: error: initializing argument 1 of
'void* zmq_threadstart(void (*)(void*), void*)' [-fpermissive]
make: *** [tests/test_concurrency_parano.o] Error 1
Here is my code exerpt :
struct arg_t {
void* ctx;
uint8_t id[8];
};
for (int i = 0; i < QT_CLIENTS; i++)
{
arg_t* args = (arg_t*) malloc(sizeof (arg_t)); // it is up to the
thread to free it
args->ctx = ctx;
int rc = build_test_stuff(i, args->id);
assert (rc == 0);
// start client thread with id
threads[i] = zmq_threadstart (&client_task, args);
}
I read many posts on stackoverflow and elsewhere with the same problem with
pthread_create, but it has not helped me.
Any idea please ?
Laurent
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev