VLA code: minor fix
[tinycc.git] / README
Commit [+]AuthorDateLineData
eb0e3e70 bellard2001-11-11 18:01:29 +00001Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler
2-----------------------------------------------------------------------
58f3296a bellard2001-10-28 15:29:01 +00003
eb0e3e70 bellard2001-11-11 18:01:29 +00004Features:
5--------
58f3296a bellard2001-10-28 15:29:01 +00006
eb0e3e70 bellard2001-11-11 18:01:29 +00007- SMALL! You can compile and execute C code everywhere, for example on
b0b2d5d2 bellard2001-12-17 21:57:01 +00008 rescue disks.
58f3296a bellard2001-10-28 15:29:01 +00009
34a14a08 bellard2001-11-18 16:33:35 +000010- FAST! tcc generates optimized x86 code. No byte code
6933ac64 bellard2002-03-03 22:44:31 +000011 overhead. Compile, assemble and link about 7 times faster than 'gcc
34a14a08 bellard2001-11-18 16:33:35 +000012 -O0'.
58f3296a bellard2001-10-28 15:29:01 +000013
eb0e3e70 bellard2001-11-11 18:01:29 +000014- UNLIMITED! Any C dynamic library can be used directly. TCC is
34a14a08 bellard2001-11-18 16:33:35 +000015 heading torward full ISOC99 compliance. TCC can of course compile
eb0e3e70 bellard2001-11-11 18:01:29 +000016 itself.
58f3296a bellard2001-10-28 15:29:01 +000017
ebe9e87c bellard2002-01-05 19:50:17 +000018- SAFE! tcc includes an optional memory and bound checker. Bound
19 checked code can be mixed freely with standard code.
20
eb0e3e70 bellard2001-11-11 18:01:29 +000021- Compile and execute C source directly. No linking or assembly
34a14a08 bellard2001-11-18 16:33:35 +000022 necessary. Full C preprocessor included.
58f3296a bellard2001-10-28 15:29:01 +000023
3bbcd307 bellard2003-04-13 21:56:00 +000024- C script supported : just add '#!/usr/local/bin/tcc -run' at the first
4dceee36 bellard2001-11-11 22:51:50 +000025 line of your C source, and execute it directly from the command
26 line.
58f3296a bellard2001-10-28 15:29:01 +000027
eb0e3e70 bellard2001-11-11 18:01:29 +000028Documentation:
29-------------
30
0de6fe6c Jov2013-03-25 22:51:52 +0800311) Installation on a i386/x86_64/arm Linux/OSX/FreeBSD host (for Windows read tcc-win32.txt)
eb0e3e70 bellard2001-11-11 18:01:29 +000032
1ef95ea3
TP
Thomas Preud'homme2013-04-08 23:26:27 +020033Note: For OSX and FreeBSD, gmake should be used instead of make.
34
dd56ab8c bellard2003-04-13 19:50:35 +000035 ./configure
1ef95ea3
TP
Thomas Preud'homme2013-04-08 23:26:27 +020036 make
37 make test
38 make install
eb0e3e70 bellard2001-11-11 18:01:29 +000039
017bbbfe
AD
Akim Demaille2012-12-21 13:55:26 +010040Alternatively, out-of-tree builds are supported: you may use different
41directories to hold build objects, kept separate from your source tree:
3f09b90d
AD
Akim Demaille2012-12-14 17:18:03 +010042
43 mkdir _build
44 cd _build
45 ../configure
1ef95ea3
TP
Thomas Preud'homme2013-04-08 23:26:27 +020046 make
47 make test
48 make install
3f09b90d Akim Demaille2012-12-14 17:18:03 +010049
0de6fe6c Jov2013-03-25 22:51:52 +080050Texi2html must be installed to compile the doc.
dd56ab8c bellard2003-04-13 19:50:35 +000051By default, tcc is installed in /usr/local/bin.
52./configure --help shows configuration options.
dc685c6b bellard2002-12-08 14:34:02 +000053
dc685c6b bellard2002-12-08 14:34:02 +000054
eb0e3e70 bellard2001-11-11 18:01:29 +0000552) Introduction
56
57We assume here that you know ANSI C. Look at the example ex1.c to know
58what the programs look like.
59
eb0e3e70 bellard2001-11-11 18:01:29 +000060The include file <tcclib.h> can be used if you want a small basic libc
61include support (especially useful for floppy disks). Of course, you
62can also use standard headers, although they are slower to compile.
63
44cea6ae bellard2003-10-05 10:21:28 +000064You can begin your C script with '#!/usr/local/bin/tcc -run' on the first
eb0e3e70 bellard2001-11-11 18:01:29 +000065line and set its execute bits (chmod a+x your_script). Then, you can
66launch the C code as a shell or perl script :-) The command line
67arguments are put in 'argc' and 'argv' of the main functions, as in
68ANSI C.
69
ebe9e87c bellard2002-01-05 19:50:17 +0000703) Examples
eb0e3e70 bellard2001-11-11 18:01:29 +000071
72ex1.c: simplest example (hello world). Can also be launched directly
34a14a08 bellard2001-11-18 16:33:35 +000073as a script: './ex1.c'.
eb0e3e70 bellard2001-11-11 18:01:29 +000074
75ex2.c: more complicated example: find a number with the four
76operations given a list of numbers (benchmark).
77
78ex3.c: compute fibonacci numbers (benchmark).
79
80ex4.c: more complicated: X11 program. Very complicated test in fact
a03346c0
TP
Thomas Preud'homme2011-07-07 12:15:43 +020081because standard headers are being used ! As for ex1.c, can also be launched
82directly as a script: './ex4.c'.
eb0e3e70 bellard2001-11-11 18:01:29 +000083
84ex5.c: 'hello world' with standard glibc headers.
85
34a14a08 bellard2001-11-18 16:33:35 +000086tcc.c: TCC can of course compile itself. Used to check the code
87generator.
eb0e3e70 bellard2001-11-11 18:01:29 +000088
dc685c6b bellard2002-12-08 14:34:02 +000089tcctest.c: auto test for TCC which tests many subtle possible bugs. Used
eb0e3e70 bellard2001-11-11 18:01:29 +000090when doing 'make test'.
91
ebe9e87c bellard2002-01-05 19:50:17 +0000924) Full Documentation
eb0e3e70 bellard2001-11-11 18:01:29 +000093
b0b2d5d2 bellard2001-12-17 21:57:01 +000094Please read tcc-doc.html to have all the features of TCC.
58f3296a bellard2001-10-28 15:29:01 +000095
e8a52a82 grischka2009-04-18 14:20:27 +020096Additional information is available for the Windows port in tcc-win32.txt.
16559cd6 bellard2005-06-17 22:07:03 +000097
eb0e3e70 bellard2001-11-11 18:01:29 +000098License:
99-------
58f3296a bellard2001-10-28 15:29:01 +0000100
770ef5ed bellard2003-05-24 14:18:56 +0000101TCC is distributed under the GNU Lesser General Public License (see
102COPYING file).
58f3296a bellard2001-10-28 15:29:01 +0000103
ebe9e87c bellard2002-01-05 19:50:17 +0000104Fabrice Bellard.