Skip to content

Instantly share code, notes, and snippets.

@nbdd0121
Last active February 9, 2022 16:49
Show Gist options
  • Save nbdd0121/0f0bae5f4e3e2b3b8695f51eee523f19 to your computer and use it in GitHub Desktop.
Save nbdd0121/0f0bae5f4e3e2b3b8695f51eee523f19 to your computer and use it in GitHub Desktop.
Archive member selection
#include <stdio.h>
__attribute__((constructor))
void a(void) {
printf("A\n");
}
void aa(void) {}
#include <stdio.h>
__attribute__((constructor))
void b(void) {
printf("B\n");
}
void bb(void) {}
void aa(void);
void bb(void);
int main(void) {
aa();
}
run: main
./main
a.o: a.c
gcc $^ -c -o $@
b.o: b.c
gcc $^ -c -o $@
foo.a: a.o b.o
ar cr $@ $^
main: main.c foo.a
gcc $^ -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment