Created
November 9, 2017 11:56
-
-
Save flatcap/e3913d98d70ac5a78ea4d5991bf4742d to your computer and use it in GitHub Desktop.
linker test
This file contains hidden or 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
#include <stdio.h> | |
#include "global.h" | |
// int global = -42; | |
void apple(void) | |
{ | |
printf("apple\n"); | |
global = 42; | |
} |
This file contains hidden or 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
#include <stdio.h> | |
#include "global.h" | |
// int global = -99; | |
void banana(void) | |
{ | |
printf("banana\n"); | |
global = 99; | |
} |
This file contains hidden or 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
#include "global.h" | |
// int global = -666; | |
int global; |
This file contains hidden or 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
extern int global; |
This file contains hidden or 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
#include <stdio.h> | |
#include "global.h" | |
void apple(void); | |
void banana(void); | |
int main() | |
{ | |
printf("global = %d\n", global); | |
apple(); | |
printf("global = %d\n", global); | |
banana(); | |
printf("global = %d\n", global); | |
return 0; | |
} |
This file contains hidden or 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
all: main | |
main: main.o libfruit.a | |
$(CC) -o main main.o -L. -lfruit | |
libfruit.a: apple.o banana.o global.o | |
ar cr libfruit.a apple.o banana.o global.o | |
clean: | |
rm -f *.o *.a main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment