Skip to main content

Output options

string
Specify the output filename for the object file, executable, or shared library.
flag
Compile only - generate an object file without linking.
flag
Compile and run the program immediately with optional arguments.

Preprocessor options

Include paths

string
Add a directory to the include file search path. Include paths are searched in the order they are specified. System include paths are always searched after user-specified paths.
Default system include paths:
  • /usr/local/include
  • /usr/include
  • PREFIX/lib/tcc/include (usually /usr/lib/tcc/include)
string
Add a directory to the system include path. Files from system include paths are treated as system headers.
flag
Do not search the default system include paths. Only search include paths explicitly provided with -I.

Macro definitions

string
Define a preprocessor symbol. If val is not provided, the value is 1. Function-like macros can also be defined.
string
Undefine a preprocessor symbol.

Include files

string
Include the specified file before processing each input file, as if #include "file" appeared at the beginning.

Preprocessing output

flag
Preprocess only - output preprocessed source to stdout or file (with -o).
flag
With -E: do not output #line directives in preprocessed output.
flag
With -E: output alternative #line directives.
flag
With -E: output #define directives along with preprocessed code.
flag
With -E: output only #define directives, no preprocessed code.
string
Pass option directly to preprocessor. Equivalent to using -opt directly.

Compilation flags

Most compilation flags support a negative form with the -fno- prefix to disable the feature.

Character type

flag
Make the char type unsigned by default.
flag
Make the char type signed by default.

Symbol behavior

flag
Do not generate common symbols for uninitialized global data. Place uninitialized globals in BSS instead.
flag
Add a leading underscore to the beginning of each C symbol (for compatibility with some platforms).

Language extensions

flag
Allow Microsoft C compiler extensions. Currently this enables anonymous struct/union declarations without an identifier to behave like unnamed members.
flag
Allow dollar signs ($) in C identifiers.

Function behavior

flag
Evaluate function arguments from right to left instead of left to right.
flag
Make extern inline behave like static inline (GNU89 semantics).

Debug and analysis

flag
Generate exception handling frame section (eh_frame). This is enabled by default.
flag
Generate code coverage instrumentation. After running the program, a .tcov file is created with coverage data.

Warning options

flag
Disable all warnings.
Most warning options support a negative form with the -Wno- prefix.
flag
Enable commonly useful warnings. Includes:
  • -Wimplicit-function-declaration
  • -Wdiscarded-qualifiers
flag
Treat all warnings as errors. Can be given an option to enable a specific warning and treat it as an error.

Specific warnings

flag
Warn when a function is called without a prior declaration or prototype.
flag
Warn when type qualifiers like const are dropped (e.g., assigning const char * to char *).
flag
Warn about unsupported GCC features and options that are ignored by TCC.
flag
Make string literals of type const char * instead of char *.

Linker options

Library paths

string
Add a directory to the library search path for the -l option.
Default library paths:
  • /usr/local/lib
  • /usr/lib
  • /lib

Libraries

string
Link with dynamic library libxxx.so or static library libxxx.a. Libraries are searched in paths specified by -L and the LIBRARY_PATH environment variable.
string
Set the path where TCC’s internal libraries and include files are located. Default is PREFIX/lib/tcc.

Library generation

flag
Generate a shared library instead of an executable.
string
Set the shared object name (DT_SONAME) to be used at runtime.
flag
Generate a statically linked executable. Links with static versions of libraries. This is not recommended as it may not work correctly with TCC.
Static linking with -static is not fully supported and may not work correctly. TCC primarily targets dynamic linking.
flag
Export global symbols to the dynamic linker. Useful when a library opened with dlopen() needs to access symbols from the main executable.
flag
Generate a relocatable object file by combining all input files.

Standard library options

flag
Do not implicitly link with the C standard library (libc), C runtime startup files, and libtcc1.
flag
Do not search the default library paths. Only search paths specified with -L and the LIBRARY_PATH environment variable.

Advanced linker options

All options starting with -Wl, are passed to the linker:
string
Set custom search path for dynamic libraries in the executable.
string
Set the ELF interpreter (dynamic linker) path.
string
Alternative syntax for setting the dynamic linker path.
flag
Create the new ELF dynamic tag DT_RUNPATH instead of the legacy DT_RPATH when setting custom library search paths.
string
Set the output format. Supported formats:
  • elf32-i386 or elf64-x86-64: ELF format (default)
  • binary: Raw binary image (executables only)
  • coff: COFF format (TMS320C67xx target only)
  • pe-i386 or pe-x86-64: PE format (Windows)
flag
Same as -rdynamic - export all symbols to dynamic linker.
flag
Same as -rdynamic - export all symbols to dynamic linker.
flag
Set the DT_SYMBOLIC ELF tag, which makes symbol resolution within the library prefer local definitions.
flag
Include all object files from subsequent static libraries, not just those needed to resolve undefined symbols.
flag
Return to normal behavior - only load objects as needed from static libraries.

Executable layout (Advanced)

string
Set the base address of the code section.
string
Set the base address of the executable.
string
Set section alignment in the executable.
string
Set file alignment (PE format only).
string
Set stack reserve size (PE format only).

Windows-specific options

string
Set PE (Windows) executable subsystem type: console, gui, wince, etc.

Debugger options

flag
Generate runtime debug information in STAB format. Provides clear error messages like test.c:68: in function 'test5()': dereferencing invalid pointer instead of just Segmentation fault.
flag
Generate runtime debug information in DWARF format instead of STAB.
flag
Generate extended DWARF debug information.
flag
Create a .pdb debug database file (Windows PE targets only).
flag
Compile with built-in memory and bounds checker. Detects memory allocation errors and array/pointer bounds violations at runtime. Implies -g.
The bounds checker (-b) adds significant runtime overhead. Only use during development and testing.
flag
Link with backtrace support and display up to N callers in stack traces. Useful with -g or -b. Defines the __TCC_BACKTRACE__ macro.
Provides access to:
Example:

Miscellaneous options

string
Define the __STDC_VERSION__ macro. Use c11 or gnu11 for C11 standard (sets to 201112), otherwise sets to 199901 (C99).
string
Specify the type of the next input file:
  • c: C source file
  • a: Assembly file
  • b: Binary file
  • n: None (reset to auto-detection)
flag
Define __OPTIMIZE__ macro for optimization level n. -O0 does not define the macro.
TCC does minimal optimization. The -O flag mainly affects preprocessor macros for conditional compilation.
flag
Preprocess with -D_REENTRANT and link with -lpthread.

Dependency generation

flag
Output Makefile dependency rules instead of compiling. Includes system headers.
flag
Like -M but only mention user header files, not system headers.
flag
Generate Makefile dependency file while also compiling.
flag
Like -MD but only mention user header files.
string
Specify the output filename for dependency information (use with -MD or -MMD).
flag
Add phony targets for each dependency (prevents make errors if headers are removed).
flag
With -run or -E: automatically define test_... macros for testing purposes.

Target-specific options

flag
Generate 32-bit code (defer to i386 cross compiler if needed).
flag
Generate 64-bit code (defer to x86_64 cross compiler if needed).
flag
Use Microsoft Visual C++ algorithm for bitfield layout instead of GCC’s algorithm.
string
Select floating-point ABI on ARM. Values: softfp or hard.
flag
Do not use SSE registers for floating-point operations on x86_64.

Ignored options

The following GCC options are recognized but ignored for compatibility:
Use -Wunsupported to get warnings about ignored GCC features and options.