Skip to content

Instantly share code, notes, and snippets.

@lchagnoleau
Last active June 7, 2024 12:38
Show Gist options
  • Save lchagnoleau/869be7c4d0a3af07fabb93720bd65786 to your computer and use it in GitHub Desktop.
Save lchagnoleau/869be7c4d0a3af07fabb93720bd65786 to your computer and use it in GitHub Desktop.
How to use `wrap` option in gcc
#include "foo.h"
#include <stdio.h>
void foo()
{
printf("foo\n");
}
#pragma once
void foo();
#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