The '''Tiny [C] Compiler''' http://fabrice.bellard.free.fr/tcc Features (from the tcc homepage) * SMALL! You can compile and execute C code everywhere, for example on rescue disks (80KB for x86 TCC executable [Larry Smith] Compress it with upx [http://upx.sourceforge.net/] and it drops to 56K.) * FAST! tcc generates optimized x86 code. No byte code overhead. Compile, assemble and link several times faster than GCC. * UNLIMITED! Any C dynamic library can be used directly. TCC is heading torward full ISOC99 compliance. TCC can of course compile itself. * SAFE! tcc includes an optional memory and bound checker. Bound checked code can be mixed freely with standard code. * Compile and execute C source directly. No linking or assembly necessary. Full C preprocessor included. * C script supported : just add '#!/usr/local/bin/tcc' at the first line of your C source, and execute it directly from the command line. * With libtcc, you can use TCC as a backend for dynamic code generation. [Reinhard Max] has tried to [Compile Tcl with tcc] on SuSE Linux. LGPL. [CMcC] has written a [tcc tcl extension] - generate dlls and even dynamically compile C into memory. ---- Is there a way to combine [critcl] and one of these small c compilers? ---- [[Of possible interest to the same readers is this [http://sdcc.sf.net] small compiler.]] [LES]: Are you sure it's for i386 only? What about this? [http://sdcc.sourceforge.net/snap.php] SDCC can generate code only for Intel 8051, Maxim 80DS390 and Zilog Z80, with Motorola 68HC08 and Microchip PIC16 and PIC18 in the works. Tcl runs on none of these, AFAIK. ---- See also: [Small is beautiful] ---- October 27, 2004 garrison@qualcomm.com I have a working version for windows, and have written a couple examples using Tcl C API's...Works pretty good... Still needs some work.... [CMcC] - Excellent. The latest version is supposed to work for windows too, the big question is: can your version create .dll files? No, what you get is a compiled memory resident code. I use it mainly to quickly test new 'C' code segments or just needed a quick fast function call to perform something (math routine)... I've compiled the tcc into a DLL and load it into tcl, then load/unload my 'C' scripts...I have put in hooks to call the tcl API so I can create new commands...The main difference is that you use the "main" function the same as the "init" call to initialize the code... example 'C' script: // sample script to test // performs MD5 checksum on file // this is a local modified tcl header file #include "tcl.h" typedef unsigned char *POINTER; typedef unsigned short int UINT2; typedef unsigned long int UINT4; #define _O_TEXT 0x4000 /* file mode is text (translated) */ #define _O_BINARY 0x8000 /* file mode is binary (untranslated) */ unsigned char PADDING[64]; ..........cut bulk of the code out................................... // tcl command to envoke static int md5_test(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv []) { nt md5_test(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *const objv []) MD5_CTX context; unsigned char digest[16]; unsigned char buffer[1024]; char tmp[33]; int x = 0; int len = 0; int fp; int fp; PADDING[0] = 0x80; for (x = 1; x < 64; ++x) { PADDING[x] = 0; } PADDING[x] = 0; char buf[256]; char buf[256]; if (objc != 2) { Tcl_SetResult(interp,"must provide a file name...", TCL_STATIC); return TCL_ERROR; } } } fp = _open(objv[1], _O_BINARY); if (fp < 0) { Tcl_SetResult(interp,"Unable to open file...", TCL_STATIC); return TCL_ERROR; } return TCL_ERROR; MD5Init (&context); while (len = _read (fp, buffer, 1024)) MD5Update (&context, buffer, len); MD5Final (digest, &context); _close (fp); se (fp); strcpy(buf, ""); strcpy(buf, ""); // compile MD5 cksum for (x = 0; x < 16 ; ++x) { sprintf (tmp, "%02x", digest[x]); strcat(buf, tmp); } } Tcl_SetResult(interp,buf,TCL_STATIC); return TCL_OK; } // main - create tcl commands here int main() { () Tcl_Interp* interp; Tcl_Interp* interp; // get interp from main global interp = (Tcl_Interp*) getInterp(); interp = (Tcl_Interp*) getInterp(); Tcl_CreateCommand(interp,"md5",(Tcl_CmdProc *)md5_test,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL); Tcl_CreateCommand(interp,"md5",(Tcl_CmdProc *)md5_test,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL); return TCL_OK; d(interp,"md5",(Tcl_CmdProc *)md5_test,(ClientData)NULL,(Tcl_CmdDeleteProc *)NULL); } ---- [Category Language]