feel free to email me at

Making weird things. Metaprogramming in C.

Just wondered will it work or not. It works.

Do not try this on platforms other then 32bit x86.

#include <stdio.h>

void f() { printf("hello, world\n"); }

char prog[6];
typedef void (*callable)();

int main() {
        prog[0] = 0xe8;
        *(int *)(prog+1) = ((char *)f)-((char *)(prog+5));
        prog[5] = 0xc3;
        ((callable)prog)();
}