Skip to content

Instantly share code, notes, and snippets.

@paulproteus
Last active August 29, 2015 14:19
Show Gist options
  • Save paulproteus/ae66d1edaf95b81b7fee to your computer and use it in GitHub Desktop.
Save paulproteus/ae66d1edaf95b81b7fee to your computer and use it in GitHub Desktop.
#include <stdio.h>
// Doing this so there is _some_ header.
int fiprintf(FILE *stream, const char *format, ...);
// Doing this to verify that we can call "fiprintf" successfully.
int main(void) {
fiprintf(stdout, "%s", "Yo.\n");
}
all: libintl.so hello
libintl.so:
gcc -c -Wall -Werror -fpic nothing.c
gcc -fpic -shared -o libintl.so nothing.c
hello:
LD_LIBRARY_PATH=. g++ -lintl hello.cxx
hello2:
g++ -Dfiprintf=fprintf hello.cxx -o hello2
#include <stdarg.h>
#include <stdio.h>
int fiprintf(FILE *stream, const char *format, ...)
{
va_list args;
va_start(args, format);
int r = vfprintf(stream, format, args);
va_end(args);
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment