Call a void* as a function without declaring a function pointer

Posted by ToxIk on Stack Overflow See other posts from Stack Overflow or by ToxIk
Published on 2010-04-14T07:50:22Z Indexed on 2010/04/14 7:53 UTC
Read the original article Hit count: 436

Filed under:
|
|
|
|

I've searched but couldn't find any results (my terminology may be off) so forgive me if this has been asked before.

I was wondering if there is an easy way to call a void* as a function in C without first declaring a function pointer and then assigning the function pointer the address;

ie. assuming the function to be called is type void(void)

void *ptr;
ptr = <some address>;
((void*())ptr)(); /* call ptr as function here */

with the above code, I get error C2066: cast to function type is illegal in VC2008

If this is possible, how would the syntax differ for functions with return types and multiple parameters?

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++