Journal Articles

CVu Journal Vol 15, #3 - Jun 2003
Browse in : All > Journals > CVu > 153 (14)

Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.

Title: Members' experiences

Author: Administrator

Date: 03 June 2003 13:15:58 +01:00 or Tue, 03 June 2003 13:15:58 +01:00

Summary: 

TCC (Tiny C Compiler)

Body: 

This is a very fast, small and new C compiler for Unix (e.g. Linux), available from http://fabrice.bellard.free.fr/tcc/. It compiles code much more quickly than the GNU compiler, and it can be used as a script interpreter with C as the scripting language (using the Unix idiom of starting scripts with "#!"). Because TCC compiles very rapidly, there is hardly any compiler overhead for small programs, and the ability to directly execute the source file without having to compile it first can be surprisingly convenient.

TCC supports modern C (for example, you can declare variables just before they are used, rather than having to put the declarations at the start of the block); using it to hack out scripts is easier than one might imagine, especially for people who have sometimes used C++ compilers in C-like ways just to avoid having to do such things as forward declarations. The advantages and disadvantages of C as a scripting language can of course be debated (there are higher level scripting languages, such as Python, which have their own advantages), but if you have a small task that you know exactly how to do in C, then it might be quicker just to write the C (as long as it doesn't get too messy or unsafe).

Of course, TCC can also be used to compile larger projects, in which case it will save a lot of compilation time. Occasionally it will expose a bug in your Unix distribution, as sometimes the provided standard libraries have only been thoroughly tested with the provided compiler (such as GCC); if you use another compiler then you might trip things up. For example, I found (and reported) that GNU libc6 is missing the alloca() function; the GNU compiler replaces it with a built-in function. The header file does say that for non-GNU compilers alloca() is defined externally, but it wasn't included in my version of the library.

I wouldn't yet want to use TCC to compile such things as the Linux kernel; I'd rather use the same compiler that the kernel developers themselves use, just in case.

I also tried LWC, http://students.ceid.upatras.gr/~sxanth/lwc/, which compiles a subset of C++ into C (and is linked to from the TCC website). The version of LWC at the time of writing is 0.5, and it couldn't yet compile any of my C++ code.

Notes: 

More fields may be available via dynamicdata ..