TCC-DOC(1) Tiny C Compiler TCC-DOC(1) NNAAMMEE tcc - Tiny C Compiler SSYYNNOOPPSSIISS usage: tcc [options] [_i_n_f_i_l_e_1 _i_n_f_i_l_e_2...] [--rruunn _i_n_f_i_l_e _a_r_g_s...] DDEESSCCRRIIPPTTIIOONN TCC options are very much like gcc options. The main difference is that TCC can also execute directly the resulting program and give it runtime arguments. Here are some examples to understand the logic: "ttcccc --rruunn aa..cc" Compile _a_._c and execute it directly "ttcccc --rruunn aa..cc aarrgg11" Compile a.c and execute it directly. arg1 is given as first argument to the main() of a.c. "ttcccc aa..cc --rruunn bb..cc aarrgg11" Compile _a_._c and _b_._c, link them together and execute them. arg1 is given as first argument to the main() of the resulting program. "ttcccc --oo mmyypprroogg aa..cc bb..cc" Compile _a_._c and _b_._c, link them and generate the executable _m_y_p_r_o_g. "ttcccc --oo mmyypprroogg aa..oo bb..oo" link _a_._o and _b_._o together and generate the executable _m_y_p_r_o_g. "ttcccc --cc aa..cc" Compile _a_._c and generate object file _a_._o. "ttcccc --cc aassmmffiillee..SS" Preprocess with C preprocess and assemble _a_s_m_f_i_l_e_._S and generate object file _a_s_m_f_i_l_e_._o. "ttcccc --cc aassmmffiillee..ss" Assemble (but not preprocess) _a_s_m_f_i_l_e_._s and generate object file _a_s_m_f_i_l_e_._o. "ttcccc --rr --oo aabb..oo aa..cc bb..cc" Compile _a_._c and _b_._c, link them together and generate the object file _a_b_._o. Scripting: TCC can be invoked from _s_c_r_i_p_t_s, just as shell scripts. You just need to add "#!/usr/local/bin/tcc -run" at the start of your C source: #!/usr/local/bin/tcc -run #include int main() { printf("Hello World\n"); return 0; } TCC can read C source code from _s_t_a_n_d_a_r_d _i_n_p_u_t when -- is used in place of iinnffiillee. Example: echo 'main(){puts("hello");}' | tcc -run - OOPPTTIIOONNSS --cc Generate an object file. --oo oouuttffiillee Put object file, executable, or dll into output file _o_u_t_f_i_l_e. --rruunn ssoouurrccee [[aarrggss......]] Compile file _s_o_u_r_c_e and run it with the command line arguments _a_r_g_s. In order to be able to give more than one argument to a script, several TCC options can be given _a_f_t_e_r the --rruunn option, separated by spaces: tcc "-run -L/usr/X11R6/lib -lX11" ex4.c In a script, it gives the following header: #!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 --vv Display TCC version. --vvvv Show included files. As sole argument, print search dirs. -vvv shows tries too. --bbeenncchh Display compilation statistics. Preprocessor options: --IIddiirr Specify an additional include path. Include paths are searched in the order they are specified. System include paths are always searched after. The default system include paths are: _/_u_s_r_/_l_o_c_a_l_/_i_n_c_l_u_d_e, _/_u_s_r_/_i_n_c_l_u_d_e and _P_R_E_F_I_X_/_l_i_b_/_t_c_c_/_i_n_c_l_u_d_e. (_P_R_E_F_I_X is usually _/_u_s_r or _/_u_s_r_/_l_o_c_a_l). --iissyysstteemm ddiirr Specify a system include path to be added to the defaults. --nnoossttddiinncc Do not search the default system include paths; only search include paths provided on the command line. --iinncclluuddee ffiillee Include ffiillee above each input file. --DDssyymm[[==vvaall]] Define preprocessor symbol ssyymm to val. If val is not present, its value is 11. Function-like macros can also be defined: --DDFF((aa))==aa++11 --UUssyymm Undefine preprocessor symbol ssyymm. --EE Preprocess only, to stdout or file (with -o). --PP Do not output "#line" directives. --PP11 Output alternative "#line" directives. --ddDD,, --ddMM Output "#define" directives. --WWpp,,--oopptt Same as --oopptt. Compilation flags: Note: each of the following options has a negative form beginning with --ffnnoo--. --ffuunnssiiggnneedd--cchhaarr Let the "char" type be unsigned. --ffssiiggnneedd--cchhaarr Let the "char" type be signed. --ffnnoo--ccoommmmoonn Do not generate common symbols for uninitialized data. --fflleeaaddiinngg--uunnddeerrssccoorree Add a leading underscore at the beginning of each C symbol. --ffmmss--eexxtteennssiioonnss Allow a MS C compiler extensions to the language. Currently this assumes a nested named structure declaration without an identifier behaves like an unnamed one. --ffddoollllaarrss--iinn--iiddeennttiiffiieerrss Allow dollar signs in identifiers --ffrreevveerrssee--ffuunnccaarrggss Evaluate function arguments right to left. --ffggnnuu8899--iinnlliinnee "extern inline" is like "static inline". --ffaassyynncchhrroonnoouuss--uunnwwiinndd--ttaabblleess Create eh_frame section [on] --fftteesstt--ccoovveerraaggee Create code coverage code. After running the resulting code an executable.tcov or sofile.tcov file is generated with code coverage. Warning options: --ww Disable all warnings. Note: each of the following warning options has a negative form beginning with --WWnnoo--. --WWiimmpplliicciitt--ffuunnccttiioonn--ddeeccllaarraattiioonn Warn about implicit function declaration (missing prototype). --WWddiissccaarrddeedd--qquuaalliiffiieerrss Warn when const is dropped. --WWuunnssuuppppoorrtteedd Warn about unsupported GCC features that are ignored by TCC. --WWwwrriittee--ssttrriinnggss Make string constants be of type "const char *" instead of "char *". --WWeerrrroorr Abort compilation if a warning is issued. Can be given an option to enable the specified warning and turn it into an error, for example --WWeerrrroorr==uunnssuuppppoorrtteedd. --WWaallll Activate some useful warnings (--WWiimmpplliicciitt--ffuunnccttiioonn--ddeeccllaarraattiioonn, --WWddiissccaarrdd--qquuaalliiffiieerrss). Linker options: --LLddiirr Specify an additional static library path for the --ll option. The default library paths are _/_u_s_r_/_l_o_c_a_l_/_l_i_b, _/_u_s_r_/_l_i_b and _/_l_i_b. --llxxxxxx Link your program with dynamic library libxxx.so or static library libxxx.a. The library is searched in the paths specified by the --LL option and LLIIBBRRAARRYY__PPAATTHH variable. --BBddiirr Set the path where the tcc internal libraries (and include files) can be found (default is _P_R_E_F_I_X_/_l_i_b_/_t_c_c). --sshhaarreedd Generate a shared library instead of an executable. --ssoonnaammee nnaammee set name for shared library to be used at runtime --ssttaattiicc Generate a statically linked executable (default is a shared linked executable). --rrddyynnaammiicc Export global symbols to the dynamic linker. It is useful when a library opened with dlopen() needs to access executable symbols. --rr Generate an object file combining all input files. --nnoossttddlliibb Don't implicitly link with libc, the C runtime files, and libtcc1. --WWll,,--nnoossttddlliibb Don't search the default paths for libraries (_/_u_s_r_/_l_o_c_a_l_/_l_i_b, _/_u_s_r_/_l_i_b and _/_l_i_b). Only the paths specified with --LL and LLIIBBRRAARRYY__PPAATTHH are searched. --WWll,,--rrppaatthh==ppaatthh Put custom search path for dynamic libraries into executable. --WWll,,--IIppaatthh --WWll,,----ddyynnaammiicc--lliinnkkeerr==ppaatthh Set the ELF interpreter (dynamic linker). This defaults to the value of the environment variable LLDD__SSOO if set, or a compiled-in default. --WWll,,----eennaabbllee--nneeww--ddttaaggss When putting a custom search path for dynamic libraries into the executable, create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH. --WWll,,----ooffoorrmmaatt==ffmmtt Use _f_m_t as output format. The supported output formats are: "elf32-i386" ELF output format (default) "binary" Binary image (only for executable output) "coff" COFF output format (only for executable output for TMS320C67xx target) --WWll,,----eexxppoorrtt--aallll--ssyymmbboollss --WWll,,----eexxppoorrtt--ddyynnaammiicc Export global symbols to the dynamic linker. It is useful when a library opened with dlopen() needs to access executable symbols. --WWll,,--ssuubbssyysstteemm==ccoonnssoollee//gguuii//wwiinnccee//...... Set type for PE (Windows) executables. --WWll,,--[[TTtteexxtt==## || sseeccttiioonn--aalliiggnnmmeenntt==## || ffiillee--aalliiggnnmmeenntt==## || iimmaaggee--bbaassee==## || ssttaacckk==##]] Modify executable layout. --WWll,,--BBssyymmbboolliicc Set DT_SYMBOLIC tag. --WWll,,--((nnoo--))wwhhoollee--aarrcchhiivvee Turn on/off linking of all objects in archives. Debugger options: --gg Generate run time stab debug information so that you get clear run time error messages: " test.c:68: in function 'test5()': dereferencing invalid pointer" instead of the laconic "Segmentation fault". --ggddwwaarrff[[--xx]] Generate run time dwarf debug information instead of stab debug information. --bb Generate additional support code to check memory allocations and array/pointer bounds. --gg is implied. --bbtt[[NN]] Display N callers in stack traces. This is useful with --gg or --bb. When activated, "__TCC_BACKTRACE__" is defined. With executables, additional support for stack traces is included. A function " int tcc_backtrace(const char *fmt, ...); " is provided to trigger a stack trace with a message on demand. Misc options: --ssttdd==vveerrssiioonn Define "__STDC_VERSION__": 201112 if vveerrssiioonn is c11 or gnu11; 199901 otherwise. --xx[[cc||aa||bb||nn]] Specify content of next input file: respectively C, assembly, binary, or none. --OO[[nn]] Same as --DD____OOPPTTIIMMIIZZEE____ except for -O0. --pptthhrreeaadd Preprocess with --DD__RREEEENNTTRRAANNTT, link with --llpptthhrreeaadd. --MM Just output makefile fragment with dependencies --MMMM Like -M except mention only user header files, not system header files. --MMDD Generate makefile fragment with dependencies. --MMMMDD Like -MD except mention only user header files, not system header files. --MMFF ddeeppffiillee Use _d_e_p_f_i_l_e as output for -MD. --MMPP Mention all dependencies as targets too. --pprriinntt--sseeaarrcchh--ddiirrss Print the configured installation directory and a list of library and include directories tcc will search. --dduummppvveerrssiioonn Print version. --ddtt With --rruunn/--EE: auto-define 'test_...' macros Target specific options: --mmmmss--bbiittffiieellddss Use an algorithm for bitfield alignment consistent with MSVC. Default is gcc's algorithm. --mmffllooaatt--aabbii ((AARRMM oonnllyy)) Select the float ABI. Possible values: "softfp" and "hard" --mmnnoo--ssssee Do not use sse registers on x86_64 --mm3322,, --mm6644 Pass command line to the i386/x86_64 cross compiler. Note: GCC options --ffxx and --mmxx are ignored. EENNVVIIRROONNMMEENNTT Environment variables that affect how tcc operates. CCPPAATTHH CC__IINNCCLLUUDDEE__PPAATTHH A colon-separated list of directories searched for include files, directories given with --II are searched first. LLIIBBRRAARRYY__PPAATTHH A colon-separated list of directories searched for libraries for the --ll option, directories given with --LL are searched first. SSEEEE AALLSSOO ccpppp(1), ggcccc(1) AAUUTTHHOORR Fabrice Bellard 0.9.28rc 2026-02-26 TCC-DOC(1)