Created
January 12, 2014 13:13
-
-
Save FlyingJester/8384427 to your computer and use it in GitHub Desktop.
You can't pass function pointers as void pointers. But you CAN pass function pointer pointers as void pointers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CallFuncPP(void *r){ | |
void **d = (void **)r; | |
void(**e)(void) = (voidFunc *)d; | |
e[0](); | |
} | |
///// | |
//Example | |
#include<csdtio> | |
void print(void){ | |
printf("Hello, world!\n"); | |
} | |
int main(int argc, char *argv[]){ | |
void(*functP)(void) = print; | |
CallFuncPP((void *)(&funcP)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment