Richard Suchenwirth 2007-10-09 - tcltcc is a Tcl extension wrapping tcc (the tiny C compiler), which was modified by MJ so it:
LGPL, download at http://code.google.com/p/tcltcc/ .
Like Odyce, it also comes with a Critcl emulation, so hopefully (at least some time in the future) people can just code against Critcl and run it with any of the three :^)
For one example usage, see ci - a tiny C interpreter.
MJ 2007-10-09 - Tclcc now also builds and works (passes the testsuite) on Linux
Simple API for building DLLs
RS 2007-10-13: Since a couple of days, tcltcc can also build shared libraries (currently only DLLs for Windows, tested on W95). Here's a simple API for that:
package require tcc set n [tcc::dll ?name?]
Prepares the making of a DLL. Name is generated if not given, and returned.
$n ccode string
Adds the string (which can be many lines) to the source buffer. Useful for #include directives, static internal functions, etc.
$n cproc name argl rtype body
Creates a Tcl command name with typed arguments argl of C return type rtype wth the specified C body.
$n write ?-name str -dir path -code string?
Produces the DLL $path/$name[info sharedlibextension] by registering the commands as specified by ccode calls, and optionally adding the inintialization code in string.
Working example (from the test suite):
test tcc-10.3 "new DLL interface" { set d [tcc::dll] $d ccode {static int fib(int n) {return n <= 2? 1 : fib(n-1) + fib(n-2);}} $d cproc fiboy {int n} int {return fib(n);} $d cproc hello {} char* {return "world";} $d write -name fiboy -code {Tcl_Eval(interp,"puts {hello Fiboy!}");} load fiboy[info sharedlibextension] list [fiboy 20] [hello] } {6765 world}
Ah, tcc is great fun... :^)