Nov 8, 2007 #1 A abdalla Member level 4 Joined Mar 22, 2006 Messages 79 Helped 2 Reputation 4 Reaction score 1 Trophy points 1,288 Activity points 1,802 pointer to function as (void *) Hi if u please i want to know how to void*-->cast to--> pointer to function give example if u pls thx thx
pointer to function as (void *) Hi if u please i want to know how to void*-->cast to--> pointer to function give example if u pls thx thx
Nov 8, 2007 #2 A abaidullah Member level 5 Joined Apr 28, 2006 Messages 81 Helped 8 Reputation 16 Reaction score 4 Trophy points 1,288 Activity points 1,608 how to cast void * to functions the pointer pointes to a memory location not the function...
Nov 11, 2007 #3 A Aqualuna Newbie level 2 Joined Nov 8, 2007 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 1,296 cast a void * to pointer to function Just wrote an example for you Its C++ style, if you need it C style letme know... Please give points if it was actually usefull... (need them bad to download a service manual) Hope it was helpfull #include <iostream> void f() { std::cout << "Hello world!!!"; } typedef void (Function)(); int main() { // Here we assign f to the void pointer void* voidPointer = f; // Here we cast it into Function* Function* functionPointer = reinterpret_cast<Function*>(voidPointer); // Now we execute it (*functionPointer)(); }
cast a void * to pointer to function Just wrote an example for you Its C++ style, if you need it C style letme know... Please give points if it was actually usefull... (need them bad to download a service manual) Hope it was helpfull #include <iostream> void f() { std::cout << "Hello world!!!"; } typedef void (Function)(); int main() { // Here we assign f to the void pointer void* voidPointer = f; // Here we cast it into Function* Function* functionPointer = reinterpret_cast<Function*>(voidPointer); // Now we execute it (*functionPointer)(); }
Nov 18, 2007 #4 E e_eja Full Member level 2 Joined Nov 15, 2003 Messages 140 Helped 4 Reputation 8 Reaction score 0 Trophy points 1,296 Activity points 1,079 void * cast to pointer function pointer to function olso support for several microntroller compiler
Nov 21, 2007 #5 MSwedan Newbie level 2 Joined Nov 21, 2007 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 1,289 void * cast to pointer to function c++ Hello OK, it is simply to do it in C Take this EX void* your_vptr; typedef void (your_func) (param1,param2,param3); your_func mem_func; mem_func = (your_func*) your_vptr; for any question contact me M.Swedan
void * cast to pointer to function c++ Hello OK, it is simply to do it in C Take this EX void* your_vptr; typedef void (your_func) (param1,param2,param3); your_func mem_func; mem_func = (your_func*) your_vptr; for any question contact me M.Swedan