[zeromq-dev] what do I do bad with zmq_threadstart ?

Pieter Hintjens ph at imatix.com
Tue Oct 22 18:35:13 CEST 2013


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 <l.alebarde at free.fr> 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
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



-- 
-
Pieter Hintjens
CEO of iMatix.com
Founder of ZeroMQ community
blog: http://hintjens.com



More information about the zeromq-dev mailing list