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

2013-10-22 Thread Laurent Alebarde

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 
(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  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@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev






___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


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

2013-10-22 Thread Mikko Koppanen
On Wed, Oct 23, 2013 at 12:29 AM, Laurent Alebarde 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
>
>

Hi,

looking at the compiler output: is client_task defined as client_task (void
**) ? The parameter should be void *.

-- Mikko
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


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

2013-10-22 Thread Pieter Hintjens
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  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@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
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


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

2013-10-22 Thread Laurent Alebarde

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@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev