Closed rksys closed 7 years ago
c4 compiles the program into binary and then immediately runs it in the built-in virtual machine interpreter. The binary is not saved to a file. So when you typed "c4 c4.c" it did compile c4.c and then interpreted the binary. Since c4.c expected a file to compile (another one!) it generated the "usage..." message and quit. If you type "c4 c4.c hello.c" what happens is that: c4 compiles c4.c and then runs the results with the argument "hello.c". Then hello.c is compiled by c4.c and ran, all within the virtual machine interpreter. The difference between running "c4 c4.c hello.c" and just "c4 hello.c" is that the hello binary is running in the virtual interpreter nested within the first interpreter.
I hope that is not too confusing! :-)
Also, there are forks of the c4 project that generate machine code for real CPU's if that is something you need.
wow, that is very clear and helpful! 👍 by the way, do you remeber the name of those:
there are forks of the c4 project that generate machine code for real CPU
I have done a bit of google search, but only find rswier/c4/
, could you please give me the address of the fork, thanks and much appreciated!
Thank you very much!
I succeeded
c4 hello.c
, then I wanna try to compile c4.c by c4 itself. I triedc4 c4.c
, it output:Then, I tried
c4 -s -d c4.c
, it output a bunch of ascii format of assembly code. which is like:So I am wondering how to compile the c4.c into binary by c4 itself. Thanks!