Skip to content

Instantly share code, notes, and snippets.

@apaszke
Created February 28, 2016 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apaszke/f754d38e09e4579fc0d3 to your computer and use it in GitHub Desktop.
Save apaszke/f754d38e09e4579fc0d3 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void print() {
printf("called!\n");
}
typedef void (*fn)();
struct callvec {
fn function;
};
struct callvec test = {
print
};
void dynamicdispatch() {
test.function();
}
int main() {
dynamicdispatch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment