Last active
June 7, 2024 12:38
-
-
Save lchagnoleau/869be7c4d0a3af07fabb93720bd65786 to your computer and use it in GitHub Desktop.
How to use `wrap` option in gcc
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 "foo.h" | |
#include <stdio.h> | |
void foo() | |
{ | |
printf("foo\n"); | |
} |
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
#pragma once | |
void foo(); |
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 "foo.h" | |
#include <stdio.h> | |
// gcc main.c foo.c -I . -o test | |
// or | |
// gcc main.c foo.c -I . -Wl,--wrap=foo -o test | |
void __wrap_foo() | |
{ | |
printf("wrap foo\n"); | |
} | |
int main() | |
{ | |
foo(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment