How to compile a C code during execution time, and get a pointer to the corresponding function?
Suppose I generate a C program during execution time: source = "int add_x_y(int x, int y){ return x + y; }"; source_size = 42; I want the following function: void* compile(char* source, int source_size); Such that: int (*f)(int,int) = compile(source, source_size); printf("%d\n",f(2,3)); Outputs: 5 And compile can't depend on external tools (compilers), as I'd like to use it in emscripten (which converts a C program to a .js file). Is that possible? Someone else can probably fill in some of the specifics better than I, but if you don't mind calling out to GCC or linking to it, it should be