Unified · Split
| @@ -33,11 +33,78 @@ generation (@xref{libtcc}). · 32 unmodified lines | |||
| 33 | @node invoke | 33 | @node invoke |
| 34 | @chapter Command line invocation | 34 | @chapter Command line invocation |
| 35 | 35 | ||
| 36 | @section Quick start | ||
| 37 | |||
| 38 | @example | ||
| 39 | usage: tcc [-c] [-o outfile] [-bench] [-Idir] [-Dsym[=val]] [-Usym] | ||
| 40 | [-g] [-b] [-llib] [-shared] [-static] | ||
| 41 | [--] infile1 [infile2... --] [infile_args...] | ||
| 42 | @end example | ||
| 43 | |||
| 44 | TCC options are a very much like gcc. The main difference is that TCC | ||
| 45 | can also execute directly the resulting program and give it runtime | ||
| 46 | arguments. | ||
| 47 | |||
| 48 | Here are some examples to understand the logic: | ||
| 49 | |||
| 50 | @table @code | ||
| 51 | @item tcc a.c | ||
| 52 | Compile a.c and execute it directly | ||
| 53 | |||
| 54 | @item tcc a.c arg1 | ||
| 55 | Compile a.c and execute it directly. arg1 is given as first argument to | ||
| 56 | the @code{main()} of a.c. | ||
| 57 | |||
| 58 | @item tcc -- a.c b.c -- arg1 | ||
| 59 | Compile a.c and b.c, link them together and execute them. arg1 is given | ||
| 60 | as first argument to the @code{main()} of the resulting program. Because | ||
| 61 | multiple C files are specified, @code{--} are necessary to clearly separate the | ||
| 62 | program arguments from the TCC options. | ||
| 63 | |||
| 64 | @item tcc -o myprog a.c b.c | ||
| 65 | Compile a.c and b.c, link them and generate the executable myprog. | ||
| 66 | |||
| 67 | @item tcc -o myprog a.o b.o | ||
| 68 | link a.o and b.o together and generate the executable myprog. | ||
| 69 | |||
| 70 | @item tcc -c -o a.o a.c | ||
| 71 | Compile a.c and generate object file a.o | ||
| 72 | |||
| 73 | @end table | ||
| 74 | |||
| 75 | Scripting: | ||
| 76 | |||
| 77 | TCC can be invoked from @emph{scripts}, just as shell scripts. You just | ||
| 78 | need to add @code{#!/usr/local/bin/tcc} at the start of your C source: | ||
| 79 | |||
| 36 | @example | 80 | @example |
| 37 | usage: tcc [-Idir] [-Dsym[=val]] [-Usym] [-llib] [-g] [-b] | 81 | #!/usr/local/bin/tcc |
| 38 | [-i infile] infile [infile_args...] | 82 | #include <stdio.h> |
| 83 | |||
| 84 | int main() | ||
| 85 | { | ||
| 86 | printf("Hello World\n"); | ||
| 87 | return 0; | ||
| 88 | } | ||
| 39 | @end example | 89 | @end example |
| 40 | 90 | ||
| 91 | @section Option summary | ||
| 92 | |||
| 93 | General Options: | ||
| 94 | |||
| 95 | @table @samp | ||
| 96 | @item -c | ||
| 97 | Generate an object file (@samp{-o} option must also be given). | ||
| 98 | |||
| 99 | @item -o outfile | ||
| 100 | Put object file, executable, or dll into output file @file{outfile}. | ||
| 101 | |||
| 102 | @item -bench | ||
| 103 | Output compilation statistics | ||
| 104 | @end table | ||
| 105 | |||
| 106 | Preprocessor options: | ||
| 107 | |||
| 41 | @table @samp | 108 | @table @samp |
| 42 | @item -Idir | 109 | @item -Idir |
| 43 | Specify an additionnal include path. The default ones are: | 110 | Specify an additionnal include path. The default ones are: |
| @@ -51,12 +118,11 @@ also be defined: @code{'-DF(a)=a+1'} · 7 unmodified lines | |||
| 51 | 118 | ||
| 52 | @item -Usym | 119 | @item -Usym |
| 53 | Undefine preprocessor symbol 'sym'. | 120 | Undefine preprocessor symbol 'sym'. |
| 121 | @end table | ||
| 54 | 122 | ||
| 55 | @item -lxxx | 123 | C compiler options: |
| 56 | Dynamically link your program with library | ||
| 57 | libxxx.so. Standard library paths are checked, including those | ||
| 58 | specified with LD_LIBRARY_PATH. | ||
| 59 | 124 | ||
| 125 | @table @samp | ||
| 60 | @item -g | 126 | @item -g |
| 61 | Generate run time debug information so that you get clear run time | 127 | Generate run time debug information so that you get clear run time |
| 62 | error messages: @code{ test.c:68: in function 'test5()': dereferencing | 128 | error messages: @code{ test.c:68: in function 'test5()': dereferencing |
| @@ -67,15 +133,24 @@ fault}. · 4 unmodified lines | |||
| 67 | Generate additionnal support code to check | 133 | Generate additionnal support code to check |
| 68 | memory allocations and array/pointer bounds. '-g' is implied. Note | 134 | memory allocations and array/pointer bounds. '-g' is implied. Note |
| 69 | that the generated code is slower and bigger in this case. | 135 | that the generated code is slower and bigger in this case. |
| 136 | @end table | ||
| 70 | 137 | ||
| 71 | @item -i file | 138 | Linker options: |
| 72 | Compile C source 'file' before main C source. With this | ||
| 73 | command, multiple C files can be compiled and linked together. | ||
| 74 | 139 | ||
| 75 | @end table | 140 | @table @samp |
| 141 | @item -lxxx | ||
| 142 | Dynamically link your program with library | ||
| 143 | libxxx.so. Standard library paths are checked, including those | ||
| 144 | specified with LD_LIBRARY_PATH. | ||
| 145 | |||
| 146 | @item -shared | ||
| 147 | Generate a shared library instead of an executable (@samp{-o} option must also be given). | ||
| 76 | 148 | ||
| 77 | Note: the @code{-o file} option to generate an ELF executable is | 149 | @item -static |
| 78 | currently unsupported. | 150 | Generate a statically linked executable (default is a shared linked |
| 151 | executable) (@samp{-o} option must also be given). | ||
| 152 | |||
| 153 | @end table | ||
| 79 | 154 | ||
| 80 | @chapter C language support | 155 | @chapter C language support |
| 81 | 156 | ||