Created
August 25, 2012 06:23
-
-
Save jclulow/3461524 to your computer and use it in GitHub Desktop.
headers hooray
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 <stdlib.h> | |
| #include <stdio.h> | |
| #include "sigh.h" | |
| int | |
| main(void) | |
| { | |
| whatever(10, 15); | |
| (whatever)(10, 15); | |
| printf("whatever @ %p\n", whatever); | |
| #undef whatever | |
| whatever(10, 15); | |
| printf("whatever @ %p\n", whatever); | |
| 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
| CC = gcc | |
| xx: sigh.o sigh.h a.c | |
| $(CC) -o xx sigh.o a.c | |
| sigh.o: sigh.c | |
| $(CC) -c -o sigh.o sigh.c | |
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> | |
| void | |
| whatever(int a, int b) | |
| { | |
| printf("FUNCTION a %d b %d\n", a, b); | |
| } | |
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
| #ifndef __SIGH_H__ | |
| #define __SIGH_H__ | |
| extern int whatever(int a, int b); | |
| #define whatever(a, b) \ | |
| do { \ | |
| printf("MACRO a %d b %d\n", (int)(a), (int)(b)); \ | |
| } while (0) | |
| #endif /* __SIGH_H__ */ |
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
| $ ./xx | |
| MACRO a 10 b 15 | |
| FUNCTION a 10 b 15 | |
| whatever @ 0x104fd4dd0 | |
| FUNCTION a 10 b 15 | |
| whatever @ 0x104fd4dd0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment