History

update

bellard committed 25 years ago

Commit eb0e3e71 parent 605a0286 files · +210 −80Browse files

Showing the changes to README (1 of 6 files). Show all

Unified · Split

README+111−31
@@ -1,49 +1,129 @@
1Tiny C Compiler - Make the best x86 Linux C compiler in less than 8192 bytes.1Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler
2-----------------------------------------------------------------------------2-----------------------------------------------------------------------
3 3
4Differences with ANSI C:4Features:
5-----------------------5--------
6 6
7- Preprocessor: only '#define xx yy' is supported. Recursive defined7- SMALL! You can compile and execute C code everywhere, for example on
8 supported. All other directives are not supported.8 rescue disks.
9 9
10- Types: int, char, void, pointers and functions are10- FAST! tcc generates optimized x86 code. No byte code overhead.
11 supported. Function pointers are also supported. struct, union and
12 typedef not supported.
13 11
14- Operations: 'x=' not supported.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.
15 15
16- Keywords: the following keywords are supported: int void char if16- Compile and execute C source directly. No linking or assembly
17 else while break return for.17 necessary. Full C preprocessor included.
18 18
19- Symbol scope: local variables supported, but they cannot have the19- C script supported : just add '#!/usr/local/bin/tcc' at the first
20 same name as global variables.20 line of your C source, and execute it directly from the command line !
21 21
22Features:22- For adventurers, tcc is conceived to be able to generate code for
23--------23 other targets.
24 24
25- SMALL! You can compile and execute C code everywhere, for example on25Documentation:
26 rescue disks.26-------------
27
281) Installation
29
30***TCC currently only work on Linux x86***.
31
32Type 'make install' to compile and install tcc in /usr/local and
33/usr/local/lib/tcc.
34
352) Introduction
36
37We assume here that you know ANSI C. Look at the example ex1.c to know
38what the programs look like.
39
40The main limitations of tcc are that you cannot use floats.
41
42The include file <tcclib.h> can be used if you want a small basic libc
43include support (especially useful for floppy disks). Of course, you
44can also use standard headers, although they are slower to compile.
45
46You can begin your C script with '#!/usr/local/bin/tcc' on the first
47line and set its execute bits (chmod a+x your_script). Then, you can
48launch the C code as a shell or perl script :-) The command line
49arguments are put in 'argc' and 'argv' of the main functions, as in
50ANSI C.
51
523) Invokation
53
54'-Idir' : specify an additionnal include path. The
55default ones are: /usr/include, /usr/lib/tcc, /usr/local/lib/tcc.
56
57'-Dsym' : define preprocessor symbol 'sym' to 1.
58
59'-lxxx' : dynamically link your program with library
60libxxx.so. Standard library paths are checked, including those
61specificed with LD_LIBRARY_PATH.
62
63Only one source code can be compiled. If you have multiple source
64files, add one which includes all your sources.
65
664) Examples
67
68ex1.c: simplest example (hello world). Can also be launched directly
69as a script: ./ex2.c.
70
71ex2.c: more complicated example: find a number with the four
72operations given a list of numbers (benchmark).
73
74ex3.c: compute fibonacci numbers (benchmark).
75
76ex4.c: more complicated: X11 program. Very complicated test in fact
77because standard headers are being used ! Currently slow because
78parsing does not use hash tables.
79
80ex5.c: 'hello world' with standard glibc headers.
81
82tcc.c: TCC can compile itself. Used to check the code generator.
83
84prog.c: auto test for TCC which tests many subtle possible bugs. Used
85when doing 'make test'.
86
87Exact differences with ANSI C:
88-----------------------------
89
901) Preprocessor
91
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!
95
96 - __LINE__, __FILE__, __DATE__, __TIME__ are currently not handled.
97
98 - #line not handled
99
1002) C language
101
102- Parsing: variables cannot be initialized ('int a = 1' or 'int tab[2] =
103 {1, 2}' not supported).
104
105- Cannot pass struct/union as value. Cannot assign struct/union (use
106 memcpy instead).
27 107
28- FAST! tcc generate x86 code. No byte code overhead.108- Types: floating point numbers are not supported.
29 109
30- Compile and execute C source directly. No linking necessary.110- (BUG) 'char' and 'short' casts do not truncate correctly.
31 111
32- C script supported : just add '#!/usr/bin/tcc' at the first line of112- 'sizeof' may not work if too complex expression is given.
33 your C source, and execute it directly from the command line !
34 113
35- All C library functions can be used via dynamic linking.114Supported C extensions:
115----------------------
36 116
37-------------------------------------------------------------------------117- 'inline' keyword is ignored.
38An even smaller compiler can be build from tcc by activating the
39define 'TINY'. The following changes from tcc:
40 118
41- Comments are not supported.
42 119
43- Parsing: No char constants. No '\r' and '\t' in strings. Only base120License:
44 10 numbers are supported.121-------
45 122
46- no 'for' loops.123TCC is distributed under the GNU Generic Public License (see COPYING
124file).
47 125
48- Operations: '?:', ',', 'x=', shifts, '&&', '||', '!', '~' not supported.126I accept only patches where you give your copyright explictely to me
127to simplify licensing issues.
49 128
129Fabrice Bellard - Nov 11, 2001.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t