update
[tinycc.git] / README
blob76fe675ac30448caa9ca2ab31189b8ed76ea899e
1 Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler
2 -----------------------------------------------------------------------
4 Features:
5 --------
7 - SMALL! You can compile and execute C code everywhere, for example on
8   rescue disks.
10 - FAST! tcc generates optimized x86 code. No byte code overhead.
12 - UNLIMITED! Any C dynamic library can be used directly. TCC is
13   heading torwards full ANSI C compliance. TCC can of course compile
14   itself.
16 - Compile and execute C source directly. No linking or assembly
17   necessary. Full C preprocessor included.
19 - C script supported : just add '#!/usr/local/bin/tcc' at the first
20   line of your C source, and execute it directly from the command line !
22 - For adventurers, tcc is conceived to be able to generate code for
23   other targets.
25 Documentation:
26 -------------
28 1) Installation
30 ***TCC currently only work on Linux x86***.
32 Type 'make install' to compile and install tcc in /usr/local and
33 /usr/local/lib/tcc.
35 2) Introduction
37 We assume here that you know ANSI C. Look at the example ex1.c to know
38 what the programs look like.
40 The main limitations of tcc are that you cannot use floats. 
42 The include file <tcclib.h> can be used if you want a small basic libc
43 include support (especially useful for floppy disks). Of course, you
44 can also use standard headers, although they are slower to compile.
46 You can begin your C script with '#!/usr/local/bin/tcc' on the first
47 line and set its execute bits (chmod a+x your_script). Then, you can
48 launch the C code as a shell or perl script :-) The command line
49 arguments are put in 'argc' and 'argv' of the main functions, as in
50 ANSI C.
52 3) Invokation
54 '-Idir' : specify an additionnal include path. The
55 default ones are: /usr/include, /usr/lib/tcc, /usr/local/lib/tcc.
57 '-Dsym' : define preprocessor symbol 'sym' to 1.
59 '-lxxx' : dynamically link your program with library
60 libxxx.so. Standard library paths are checked, including those
61 specificed with LD_LIBRARY_PATH.
63 Only one source code can be compiled. If you have multiple source
64 files, add one which includes all your sources.
66 4) Examples
68 ex1.c: simplest example (hello world). Can also be launched directly
69 as a script: ./ex2.c.
71 ex2.c: more complicated example: find a number with the four
72 operations given a list of numbers (benchmark).
74 ex3.c: compute fibonacci numbers (benchmark).
76 ex4.c: more complicated: X11 program. Very complicated test in fact
77 because standard headers are being used ! Currently slow because
78 parsing does not use hash tables.
80 ex5.c: 'hello world' with standard glibc headers.
82 tcc.c: TCC can compile itself. Used to check the code generator.
84 prog.c: auto test for TCC which tests many subtle possible bugs. Used
85 when doing 'make test'.
87 Exact differences with ANSI C:
88 -----------------------------
90 1) Preprocessor
92  - the preprocessor tokens are the same as C. It means that in some
93   rare cases, preprocessed numbers are not handled exactly as in ANSI
94   C. This approach has the advantage of being simpler and FAST!
96  - __LINE__, __FILE__, __DATE__, __TIME__ are currently not handled.
98  - #line not handled
100 2) C language
102 - Parsing: variables cannot be initialized ('int a = 1' or 'int tab[2] =
103   {1, 2}' not supported).
105 - Cannot pass struct/union as value. Cannot assign struct/union (use
106   memcpy instead).
108 - Types: floating point numbers are not supported.
110 - (BUG) 'char' and 'short' casts do not truncate correctly.
112 - 'sizeof' may not work if too complex expression is given.
114 Supported C extensions:
115 ----------------------
117 - 'inline' keyword is ignored.
120 License:
121 -------
123 TCC is distributed under the GNU Generic Public License (see COPYING
124 file). 
126 I accept only patches where you give your copyright explictely to me
127 to simplify licensing issues.
129 Fabrice Bellard - Nov 11, 2001.