Free Educational Resource Center for teachers and students. Includes Interviews,
Sourcecode, Free Software, Research Papers, Articles, Tutorials and much more..
     R E S E A R C H A C T I V I T Y . C O M
Our Fellow Research Center for Ph.D Schollars
Home About Submit & Earn Archives: C And C + + Programming » Dev Packages » Interviews » Php Mysql Programming » Windows Programming
search
C And C Plus Plus Programming > tcc efficient c compiler discovery

There are many C compilers available around you, some are free and some are packaged as commercial products. The ones you definitely already know are:


   Microsoft Compilers
   GNU Free Compilers (GCC, MingW)
   Digital Mars Free Compilers
   Borland Free Compiler tools
   Watcom Compiler
   Intel Compilers
   LCC
   and many more listed here


Our talk is most probably around Microsoft Windows Programming. So the product being presented is yet another C Compiler (not C++), that is faster than all of the the above mentioned compilers. When we use the word fast, that actually means the time required for compiling and linking a C source file.



TCC - Tiny C Compiler C99 compliant, is faster than all of above mentioned compilers. TCC is developed by Fabrice Bellard (a genuine researcher), may be obtained from
here. A quick comparison of TCC with GCC posted by the author is

Compiler		Time(s)	lines/second	MBytes/second

TinyCC 0.9.22 2.27 859000 29.6
GCC 3.2 -O0 20.0 98000 3.4


This Tiny C compiler is not actually a tiny discovery in the field of compiler construction, compiling very huge sourcecode files in fraction of second is indeed remarkable feature of this compiler.

One more remarkable feature of this C compiler is, it produces amazingly small executables, which is basically by stripping unwanted segments from final executable. It allows linking of static as well as shared libraries, yet does not affect the compilation time.

Why is it that fast?
   It has built-in assembler
   It has built-in linker, that does not start yet antoehr process for linkage.

Let us conduct a test. Compiling test.c with following code:


#ifdef __TINYC__
#include <winapi/windows.h>
#else
#include <windows.h>
#endif

#define uint unsigned int
#define ushort unsigned short
#define BLOCK_SIZE sizeof(uint)
#define E08 256
#define E16 65535
#define E32 4294967295 // div 10 //131070
ushort temp[429496729];


typedef void (*PV)();

void test() {
MessageBox(0,L"struct embedded function",0,0);
}

typedef struct {
int x;
int y;
float z;
PV func;
} abc;

int main() {
HWND wnd = CreateWindowEx(
0,WC_DIALOG, L"Embed IE in C", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
200,100,800,500,NULL,NULL,NULL,NULL
);
abc a;
a.func = &test;
a.func();
return 0;
}



Compiler stats:
13040 idents, 14753 lines, 485997 bytes, 0.032 s, 461031 lines/s, 15.2 MB/s



Commandline instructions:
>tcc -DUNICODE -D_UNICODE -bench -Llib -Iinclude -Iinclude/winapi -lkernel32 -luser32 -lgdi32 test.c -o test.exe


Producing executable of size: 1,536 bytes (1.5 kb)
Compressed to RAR produced: 616 bytes


It can be really handy for producing really efficient and small programs (100% free of cost), example worth trying may be compiling GTK+ with tcc.

Download TCC here.


Send your reviews on article to