Output options
Specify the output filename for the object file, executable, or shared library.
Compile only - generate an object file without linking.
Compile and run the program immediately with optional arguments.
Preprocessor options
Include paths
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.
/usr/local/include/usr/includePREFIX/lib/tcc/include(usually/usr/lib/tcc/include)
Add a directory to the system include path. Files from system include paths are treated as system headers.
Do not search the default system include paths. Only search include paths explicitly provided with
-I.Macro definitions
Define a preprocessor symbol. If
val is not provided, the value is 1. Function-like macros can also be defined.Undefine a preprocessor symbol.
Include files
Include the specified file before processing each input file, as if
#include "file" appeared at the beginning.Preprocessing output
Preprocess only - output preprocessed source to stdout or file (with
-o).With
-E: do not output #line directives in preprocessed output.With
-E: output alternative #line directives.With
-E: output #define directives along with preprocessed code.With
-E: output only #define directives, no preprocessed code.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
Make the
char type unsigned by default.Make the
char type signed by default.Symbol behavior
Do not generate common symbols for uninitialized global data. Place uninitialized globals in BSS instead.
Add a leading underscore to the beginning of each C symbol (for compatibility with some platforms).
Language extensions
Allow Microsoft C compiler extensions. Currently this enables anonymous struct/union declarations without an identifier to behave like unnamed members.
Allow dollar signs (
$) in C identifiers.Function behavior
Evaluate function arguments from right to left instead of left to right.
Make
extern inline behave like static inline (GNU89 semantics).Debug and analysis
Generate exception handling frame section (
eh_frame). This is enabled by default.Generate code coverage instrumentation. After running the program, a
.tcov file is created with coverage data.Warning options
Disable all warnings.
Most warning options support a negative form with the
-Wno- prefix.Enable commonly useful warnings. Includes:
-Wimplicit-function-declaration-Wdiscarded-qualifiers
Treat all warnings as errors. Can be given an option to enable a specific warning and treat it as an error.
Specific warnings
Warn when a function is called without a prior declaration or prototype.
Warn when type qualifiers like
const are dropped (e.g., assigning const char * to char *).Warn about unsupported GCC features and options that are ignored by TCC.
Make string literals of type
const char * instead of char *.Linker options
Library paths
Add a directory to the library search path for the
-l option./usr/local/lib/usr/lib/lib
Libraries
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.Set the path where TCC’s internal libraries and include files are located. Default is
PREFIX/lib/tcc.Library generation
Generate a shared library instead of an executable.
Set the shared object name (DT_SONAME) to be used at runtime.
Generate a statically linked executable. Links with static versions of libraries. This is not recommended as it may not work correctly with TCC.
Export global symbols to the dynamic linker. Useful when a library opened with
dlopen() needs to access symbols from the main executable.Generate a relocatable object file by combining all input files.
Standard library options
Do not implicitly link with the C standard library (
libc), C runtime startup files, and libtcc1.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:
Set custom search path for dynamic libraries in the executable.
Set the ELF interpreter (dynamic linker) path.
Alternative syntax for setting the dynamic linker path.
Create the new ELF dynamic tag
DT_RUNPATH instead of the legacy DT_RPATH when setting custom library search paths.Set the output format. Supported formats:
elf32-i386orelf64-x86-64: ELF format (default)binary: Raw binary image (executables only)coff: COFF format (TMS320C67xx target only)pe-i386orpe-x86-64: PE format (Windows)
Same as
-rdynamic - export all symbols to dynamic linker.Same as
-rdynamic - export all symbols to dynamic linker.Set the
DT_SYMBOLIC ELF tag, which makes symbol resolution within the library prefer local definitions.Include all object files from subsequent static libraries, not just those needed to resolve undefined symbols.
Return to normal behavior - only load objects as needed from static libraries.
Executable layout (Advanced)
Set the base address of the code section.
Set the base address of the executable.
Set section alignment in the executable.
Set file alignment (PE format only).
Set stack reserve size (PE format only).
Windows-specific options
Set PE (Windows) executable subsystem type:
console, gui, wince, etc.Debugger options
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.Generate runtime debug information in DWARF format instead of STAB.
Generate extended DWARF debug information.
Create a
.pdb debug database file (Windows PE targets only).Compile with built-in memory and bounds checker. Detects memory allocation errors and array/pointer bounds violations at runtime. Implies
-g.Link with backtrace support and display up to N callers in stack traces. Useful with
-g or -b. Defines the __TCC_BACKTRACE__ macro.Miscellaneous options
Define the
__STDC_VERSION__ macro. Use c11 or gnu11 for C11 standard (sets to 201112), otherwise sets to 199901 (C99).Specify the type of the next input file:
c: C source filea: Assembly fileb: Binary filen: None (reset to auto-detection)
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.Preprocess with
-D_REENTRANT and link with -lpthread.Dependency generation
Output Makefile dependency rules instead of compiling. Includes system headers.
Like
-M but only mention user header files, not system headers.Generate Makefile dependency file while also compiling.
Like
-MD but only mention user header files.Specify the output filename for dependency information (use with
-MD or -MMD).Add phony targets for each dependency (prevents make errors if headers are removed).
With
-run or -E: automatically define test_... macros for testing purposes.Target-specific options
Generate 32-bit code (defer to i386 cross compiler if needed).
Generate 64-bit code (defer to x86_64 cross compiler if needed).
Use Microsoft Visual C++ algorithm for bitfield layout instead of GCC’s algorithm.
Select floating-point ABI on ARM. Values:
softfp or hard.Do not use SSE registers for floating-point operations on x86_64.