Skip to content

Instantly share code, notes, and snippets.

@luser
Last active January 9, 2018 14:23
Show Gist options
  • Save luser/47a445019427cc987ed26196dae3a4aa to your computer and use it in GitHub Desktop.
Save luser/47a445019427cc987ed26196dae3a4aa to your computer and use it in GitHub Desktop.
*~
libcallback.so
weak
#include <stdio.h>
void callback() {
printf("Hello from libcallback!\n");
}
all: weak libcallback.so
weak: weak.c
$(CC) -o $@ $<
libcallback.so: callback.c
$(CC) -o $@ $< -shared
void __attribute__((weak)) callback();
int main(int argc, char** argv) {
if (callback) {
callback();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment