Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat a.c
- #include "h.h"
- void a(void)
- {
- inc(__func__);
- }
- $ cat b.c
- #include "h.h"
- void b(void)
- {
- inc(__func__);
- }
- $ cat counter.c
- #include <stdio.h>
- void inc(const char *s)
- {
- static int counter = 0;
- printf("%s:\t%d\n", s, counter++);
- }
- $ cat main.c
- #include <stdio.h>
- #include "h.h"
- int main()
- {
- a();
- b();
- inc(__func__);
- a();
- b();
- inc(__func__);
- a();
- b();
- inc(__func__);
- return 0;
- }
- $ cat h.h
- void inc(const char *s);
- void a(void);
- void b(void);
- $ gcc -Wall -c -o main.o main.c
- $ gcc -Wall -c -o a.o a.c
- $ gcc -Wall -c -o b.o b.c
- $ gcc -Wall -c -o counter.o counter.c
- $ gcc main.o a.o b.o counter.o -o main
- $ ./main
- a: 0
- b: 1
- main: 2
- a: 3
- b: 4
- main: 5
- a: 6
- b: 7
- main: 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement