So, I want to compile and run a string of C source code, where the string is a const char* and represents an entire program. It should be taken from either a constant or constructed string, such as
const char* prog = "#include <stdio.h> int main(void) {puts(\"foo\"); return 0;}"
I have already tried tcclib, but it currently doesn't build on Mac OS and due to lack of a consistent maintainer I don't think it's a viable way to do this.
I am mainly asking about this as a means to have a backend for a programming language that compiles to C. If there is some library function in gcc or clang, that would work too.
Note: This is specifically about compiling C code from C, not injecting it into a process.