Skip to content

Instantly share code, notes, and snippets.

@wancw
Created January 23, 2013 14:05
Show Gist options
  • Save wancw/4605980 to your computer and use it in GitHub Desktop.
Save wancw/4605980 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef void (*func_ptr_t)(int x, ...);
void foo(int x) {
printf("foo(%d)\n", x);
}
void bar(int x, int y, int z) {
printf("foo(%d, %d, %d)\n", x, y, z);
}
int main() {
func_ptr_t fptr;
fptr = (func_ptr_t) foo;
fptr(1,2); // foo(1)
fptr = (func_ptr_t) bar;
fptr(1,2); // bar(1,2,UNDEFINED)
fptr(1,2,3); // bar(1,2,3)
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment