Richard Suchenwirth 2007-10-09 - Playing with tcltcc and its Critcl emulation, I had the idea of writing a very little C "compiler" which takes a well-formed C source, compiles and executes it, so more along the lines of a C interpreter.
One problem I encountered is that char** seems not to be supported yet, so for simplification I made argv a single string. Here's my script (ridiculously simple, indeed):
#!/usr/bin/env tclsh #-- ci.tcl -- a tiny C interpreter built on tcltcc package require critcl set f [open [lindex $argv 0]] set data [read $f] critcl::ccode $data critcl::cproc main {char* argv} int {main(1,argv);} main [lindex $argv 1]
and a tiny program to test it with (ci_test.c):
/* demo program for ci.tcl */ #include <stdio.h> int main(int argc, char* argv) { printf("hello, %s\n", argv); return 0; }
which is yet another solution for the "hello, world" problem:
/Tcl/lib/tcc02> ci.tcl ci_test.c world hello, world