Re: How can I access the worker thread data ?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Mihajlo Cvetanovic (mac_at_RnEeMtOsVeEt.co.yu)
Date: 11/19/04


Date: Fri, 19 Nov 2004 17:38:13 +0100

Doug Harrison [MVP] wrote:

> Mihajlo Cvetanovic wrote:
>
>>Liviu Andron wrote:
>>
>>>CData* pData = dynamic_cast<CData*>(pParam);
>>>
>>>Isn't there supposed to be "reinterpret_cast" ?
>>
>>dynamic_cast should return zero if pParam never was of type CData*.
>
> No. As stated earlier, pParam has the type void*. The dynamic_cast operator
> cannot cast from void*, only to, and then only if pParam is of a polymorphic
> type, in which case, it returns a pointer to the complete object.

OK, I stand corrected. So, is there at all a way to check that some
void* actually points to some CData*? Maybe like this:

dynamic_cast<CData*>(reinterpret_cast<CData*>(pParam)) != NULL



Relevant Pages

  • Re: Can I Trust Pointer Arithmetic In Re-Allocated Memory?
    ... You can't do pointer arithmetic on a void* value. ... qsort behaves in a manner consistent with its specification. ... actually works as advertised...but doesn't mean that the cast is ...
    (comp.lang.c)
  • Re: About casts (and pointers)
    ... > a cast). ... > the implementation's (void **) representation and length. ... Your sometype ** pointer is presumably pointing at ...
    (comp.lang.c)
  • Re: dynamic_cast does not work as specified
    ... then p is a pointer to an object of type SubThing. ... SubThing* via a C-style cast. ... virtual void ShowPURE; ... type-id must be a derived class of expression [note that the simple explanation could be ...
    (microsoft.public.vc.mfc)
  • Re: Common misconceptions about C (C95)
    ... Cast it to suitable type instead. ... The void and void * types come from C++ which has a better rules for them. ... object as an array of bytes (unsigned char *). ... it's okay for that pointer to be a pointer to unsigned char *. ...
    (comp.lang.c)
  • Re: Newbie Warlock Looking For Advice
    ... cast without interruption. ... Shadowbolts would occasionally draw aggro off the void, ... You also have to pay attention to your gear -- when I first started playing, ...
    (alt.games.warcraft)