[OT] This feels wrong (pthreads question)
nick at leippe.com
Mon Jan 29 12:15:15 MST 2007
On Sunday 28 January 2007 14:22, Steve wrote:
> Now my code looks like
> <my third try>
> Sender* Client = new Sender(messageIP.c_str(), mI_port);
> pthread_t t;
> pthread_create( &t, 0,runObject, (void*)Client);
> </end third try>
> And it works, but it feels very wrong to me. Having to cast the
> object to void, then recast back to it's original form, seems like a
> lot of overhead as well as being dangerous. And it has to occur every
> 250 ms, which seems like alot of recasting to me.
In C++ (and C), there's no overhead in casting pointer types as there's no
change in physical representation. It just alters the meaning of the
pointer's target for the compiler.
As for being dangerous, absolutely.
More information about the PLUG