(See also Richard Suchenwirth's C code generators page.)
The C Runtime In Tcl is a self-contained package to build C code into an extension on the fly. It is somewhat inspired by Brian Ingerson's Inline for Perl, but Critcl is considerably more lightweight. [While Python also has an Inline [1 ], it apparently has no direct genetic connection to Critcl.]
The idea is to wrap C code into something that will compile into a Tcl extension, and then also fire up the compiler. Compiled chunks will be cached in your ~/.critcl/ directory, so subsequent use will be instant.
Critcl Wiki Resources:
The main definition is "critcl::cproc", which lets you define a (surprise) C proc, with C code as body. Args and return values must be typed. There are no default args or ways to pass more sophisticated data items than int/long/float/double/char* for now.
There is also a "critcl::ccode" call, to inject C code as is, and a "ccommand" call, which ties code to the Tcl_CreateObjCommand without further wrapping.
The use of Tcl stubs, and the fact that this extension has all include files it needs to make compilation self-contained, means that this is a pure Tcl package, which should work with any (8.1 and up) installation of Tcl. Most importantly, Critcl does not care a bit where Tcl was installed, nor even whether it was built as a static or as a dynamic executable.
This is a working demo, but it is still young. (It's now rather more mature - KJN) It will for now blindly use "gcc" to do the compile and has somewhat rudimentary error handling. Critcl has been verified to work on Linux and Win NT4 (MinGW) so far.
The required md5 command and other dependencies are provided as part of the Critcl starpack.
More news on newer rev's of Critcl, or rather the "CritLib" where it is included:
A dated article [5 ] has background information on interpreted C.
What: Embedded C (EC) Where: ftp://ftp.reed.edu/pub/users/greaber/ec-0.1.tar.gz Description: Allows you to include C code in your Tcl scripts, compiling and dynamically loading it on the fly. The code will also be cached so the next time you run the program, you don't wait for it to compile. Known to work on DEC OSF/1 V3.2 and SunOS 5.5. Not yet ported to Macintosh or Windows. Updated: 09/1996 Contact: mailto:[email protected] (Grant Reaber)
George Petasis: There is a small tcl extension (tBuild - http://sourceforge.net/projects/tbuild/ ) which will compile and link a Tcl C extension by looking in the tclConfig.sh under unix and detecting visual studio from the registry under windows. It would be nice addition to Critcl to build code with, and not be limited to only gcc under unix.