Skip to content

Instantly share code, notes, and snippets.

@skejeton
Created January 27, 2020 12:41
Show Gist options
  • Save skejeton/eaaa638fbc06c75d3ee7943ff1b30939 to your computer and use it in GitHub Desktop.
Save skejeton/eaaa638fbc06c75d3ee7943ff1b30939 to your computer and use it in GitHub Desktop.
#include <stdio.h>
static void sayhi(char *text)
{
printf("hi, %s", text);
}
struct {
void (*sayhi)(char*);
} __MODULE_ANOTHER_MODULE_C = {&sayhi};
#include "modular.c"
#define ns __MODULE_MODULAR_C
#include "anothermodule.c"
#define am __MODULE_ANOTHER_MODULE_C
int main()
{
ns.print("Hi\n");
am.sayhi("me\n");
return 0;
}
#include <stdio.h>
static void print(char *text)
{
printf("%s", text);
}
struct {
void (*print)(char*);
} __MODULE_MODULAR_C = {&print};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment