> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/TinyCC/tinycc/llms.txt
> Use this file to discover all available pages before exploring further.

# Command-line options

> Complete reference for all TCC command-line options and flags

## Output options

**-o outfile** `string`

Specify the output filename for the object file, executable, or shared library.

```bash theme={null}
# Generate executable
tcc -o myprogram source.c

# Generate object file
tcc -c -o myobject.o source.c

# Generate shared library
tcc -shared -o libmylib.so mylib.c
```

**-c** `flag`

Compile only - generate an object file without linking.

**-run** `flag`

Compile and run the program immediately with optional arguments.

## Preprocessor options

### Include paths

**-Idir** `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.

```bash theme={null}
tcc -I/usr/local/mylib/include -I./include source.c
```

Default system include paths:

* `/usr/local/include`
* `/usr/include`
* `PREFIX/lib/tcc/include` (usually `/usr/lib/tcc/include`)

**-isystem dir** `string`

Add a directory to the system include path. Files from system include paths are treated as system headers.

```bash theme={null}
tcc -isystem /opt/include source.c
```

**-nostdinc** `flag`

Do not search the default system include paths. Only search include paths explicitly provided with `-I`.

```bash theme={null}
tcc -nostdinc -I./include source.c
```

### Macro definitions

**-Dsym\[=val]** `string`

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

```bash theme={null}
# Define simple macro
tcc -DDEBUG source.c

# Define macro with value
tcc -DVERSION=2 source.c

# Define function-like macro
tcc -D'MAX(a,b)=((a)>(b)?(a):(b))' source.c
```

**-Usym** `string`

Undefine a preprocessor symbol.

```bash theme={null}
tcc -U__STDC__ source.c
```

### Include files

**-include file** `string`

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

```bash theme={null}
tcc -include config.h source.c
```

### Preprocessing output

**-E** `flag`

Preprocess only - output preprocessed source to stdout or file (with `-o`).

**-P** `flag`

With `-E`: do not output `#line` directives in preprocessed output.

**-P1** `flag`

With `-E`: output alternative `#line` directives.

**-dD** `flag`

With `-E`: output `#define` directives along with preprocessed code.

**-dM** `flag`

With `-E`: output only `#define` directives, no preprocessed code.

```bash theme={null}
# Standard preprocessing
tcc -E source.c

# Preprocessing without line directives
tcc -E -P source.c -o source.i

# Show all macros
tcc -E -dM - < /dev/null
```

**-Wp,-opt** `string`

Pass option directly to preprocessor. Equivalent to using `-opt` directly.

## Compilation flags

> [!NOTE]
>
> Most compilation flags support a negative form with the `-fno-` prefix to disable the feature.

### Character type

**-funsigned-char** `flag`

Make the `char` type unsigned by default.

**-fsigned-char** `flag`

Make the `char` type signed by default.

```bash theme={null}
tcc -funsigned-char source.c
```

### Symbol behavior

**-fno-common** `flag`

Do not generate common symbols for uninitialized global data. Place uninitialized globals in BSS instead.

**-fleading-underscore** `flag`

Add a leading underscore to the beginning of each C symbol (for compatibility with some platforms).

### Language extensions

**-fms-extensions** `flag`

Allow Microsoft C compiler extensions. Currently this enables anonymous struct/union declarations without an identifier to behave like unnamed members.

```c theme={null}
// Enabled with -fms-extensions
struct {
    int x;
    struct {
        int y;
        int z;
    };  // Anonymous struct - members accessible directly
} data;
// Access: data.y, data.z
```

**-fdollars-in-identifiers** `flag`

Allow dollar signs (`$`) in C identifiers.

```c theme={null}
int my$variable = 42;  // Valid with -fdollars-in-identifiers
```

### Function behavior

**-freverse-funcargs** `flag`

Evaluate function arguments from right to left instead of left to right.

**-fgnu89-inline** `flag`

Make `extern inline` behave like `static inline` (GNU89 semantics).

### Debug and analysis

**-fasynchronous-unwind-tables** `flag`

Generate exception handling frame section (`eh_frame`). This is enabled by default.

**-ftest-coverage** `flag`

Generate code coverage instrumentation. After running the program, a `.tcov` file is created with coverage data.

```bash theme={null}
tcc -ftest-coverage program.c -o program
./program
# Creates: program.tcov
```

## Warning options

**-w** `flag`

Disable all warnings.

```bash theme={null}
tcc -w source.c
```

> [!NOTE]
>
> Most warning options support a negative form with the `-Wno-` prefix.

**-Wall** `flag`

Enable commonly useful warnings. Includes:

* `-Wimplicit-function-declaration`
* `-Wdiscarded-qualifiers`

**-Werror** `flag`

Treat all warnings as errors. Can be given an option to enable a specific warning and treat it as an error.

```bash theme={null}
# Treat all warnings as errors
tcc -Werror source.c

# Treat only unsupported warnings as errors
tcc -Werror=unsupported source.c
```

### Specific warnings

**-Wimplicit-function-declaration** `flag`

Warn when a function is called without a prior declaration or prototype.

**-Wdiscarded-qualifiers** `flag`

Warn when type qualifiers like `const` are dropped (e.g., assigning `const char *` to `char *`).

**-Wunsupported** `flag`

Warn about unsupported GCC features and options that are ignored by TCC.

**-Wwrite-strings** `flag`

Make string literals of type `const char *` instead of `char *`.

```bash theme={null}
tcc -Wall -Wwrite-strings source.c
```

## Linker options

### Library paths

**-Ldir** `string`

Add a directory to the library search path for the `-l` option.

```bash theme={null}
tcc -L/usr/local/lib -L./lib source.c
```

Default library paths:

* `/usr/local/lib`
* `/usr/lib`
* `/lib`

### Libraries

**-lxxx** `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.

```bash theme={null}
# Link with math library
tcc source.c -lm

# Link with multiple libraries
tcc source.c -lpthread -lm -lrt
```

**-Bdir** `string`

Set the path where TCC's internal libraries and include files are located. Default is `PREFIX/lib/tcc`.

### Library generation

**-shared** `flag`

Generate a shared library instead of an executable.

**-soname name** `string`

Set the shared object name (DT\_SONAME) to be used at runtime.

**-static** `flag`

Generate a statically linked executable. Links with static versions of libraries. This is not recommended as it may not work correctly with TCC.

> [!WARNING]
>
> Static linking with `-static` is not fully supported and may not work correctly. TCC primarily targets dynamic linking.

**-rdynamic** `flag`

Export global symbols to the dynamic linker. Useful when a library opened with `dlopen()` needs to access symbols from the main executable.

**-r** `flag`

Generate a relocatable object file by combining all input files.

### Standard library options

**-nostdlib** `flag`

Do not implicitly link with the C standard library (`libc`), C runtime startup files, and `libtcc1`.

**-Wl,-nostdlib** `flag`

Do not search the default library paths. Only search paths specified with `-L` and the `LIBRARY_PATH` environment variable.

```bash theme={null}
# Compile without standard library
tcc -nostdlib -o program start.o program.c
```

### Advanced linker options

All options starting with `-Wl,` are passed to the linker:

**-Wl,-rpath=path** `string`

Set custom search path for dynamic libraries in the executable.

```bash theme={null}
tcc -Wl,-rpath=/opt/lib source.c
```

**-Wl,--dynamic-linker=path** `string`

Set the ELF interpreter (dynamic linker) path.

**-Wl,-Ipath** `string`

Alternative syntax for setting the dynamic linker path.

**-Wl,--enable-new-dtags** `flag`

Create the new ELF dynamic tag `DT_RUNPATH` instead of the legacy `DT_RPATH` when setting custom library search paths.

**-Wl,--oformat=fmt** `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)

```bash theme={null}
# Generate raw binary
tcc -Wl,--oformat=binary bootloader.c -o boot.bin
```

**-Wl,--export-all-symbols** `flag`

Same as `-rdynamic` - export all symbols to dynamic linker.

**-Wl,--export-dynamic** `flag`

Same as `-rdynamic` - export all symbols to dynamic linker.

**-Wl,-Bsymbolic** `flag`

Set the `DT_SYMBOLIC` ELF tag, which makes symbol resolution within the library prefer local definitions.

**-Wl,--whole-archive** `flag`

Include all object files from subsequent static libraries, not just those needed to resolve undefined symbols.

**-Wl,--no-whole-archive** `flag`

Return to normal behavior - only load objects as needed from static libraries.

```bash theme={null}
tcc -Wl,--whole-archive -lmylib -Wl,--no-whole-archive source.c
```

### Executable layout (Advanced)

**-Wl,-Ttext=address** `string`

Set the base address of the code section.

**-Wl,--image-base=address** `string`

Set the base address of the executable.

**-Wl,--section-alignment=size** `string`

Set section alignment in the executable.

**-Wl,--file-alignment=size** `string`

Set file alignment (PE format only).

**-Wl,--stack=size** `string`

Set stack reserve size (PE format only).

### Windows-specific options

**-Wl,--subsystem=type** `string`

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

```bash theme={null}
tcc -Wl,--subsystem=console program.c -o program.exe
```

## Debugger options

**-g** `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`.

```bash theme={null}
tcc -g program.c -o program
```

**-gdwarf** `flag`

Generate runtime debug information in DWARF format instead of STAB.

**-gdwarf-x** `flag`

Generate extended DWARF debug information.

**-g.pdb** `flag`

Create a `.pdb` debug database file (Windows PE targets only).

**-b** `flag`

Compile with built-in memory and bounds checker. Detects memory allocation errors and array/pointer bounds violations at runtime. Implies `-g`.

```bash theme={null}
tcc -b program.c -o program
./program
# Runtime bounds checking active
```

> [!WARNING]
>
> The bounds checker (`-b`) adds significant runtime overhead. Only use during development and testing.

**-bt\[N]** `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:

```c theme={null}
int tcc_backtrace(const char *fmt, ...);
```

Example:

```bash theme={null}
# Show up to 10 callers in stack traces
tcc -bt10 -g program.c -o program
```

## Miscellaneous options

**-std=version** `string`

Define the `__STDC_VERSION__` macro. Use `c11` or `gnu11` for C11 standard (sets to `201112`), otherwise sets to `199901` (C99).

```bash theme={null}
tcc -std=c11 source.c
```

**-x type** `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)

```bash theme={null}
tcc -xc header.h -xn source.c
```

**-O\[n]** `flag`

Define `__OPTIMIZE__` macro for optimization level `n`. `-O0` does not define the macro.

```bash theme={null}
tcc -O2 source.c
```

> [!NOTE]
>
> TCC does minimal optimization. The `-O` flag mainly affects preprocessor macros for conditional compilation.

**-pthread** `flag`

Preprocess with `-D_REENTRANT` and link with `-lpthread`.

```bash theme={null}
tcc -pthread threaded_program.c
```

### Dependency generation

**-M** `flag`

Output Makefile dependency rules instead of compiling. Includes system headers.

**-MM** `flag`

Like `-M` but only mention user header files, not system headers.

**-MD** `flag`

Generate Makefile dependency file while also compiling.

**-MMD** `flag`

Like `-MD` but only mention user header files.

**-MF depfile** `string`

Specify the output filename for dependency information (use with `-MD` or `-MMD`).

**-MP** `flag`

Add phony targets for each dependency (prevents make errors if headers are removed).

```bash theme={null}
# Generate dependencies while compiling
tcc -MMD -MF source.d -c source.c

# Generate only dependencies
tcc -MM source.c > source.d
```

**-dt** `flag`

With `-run` or `-E`: automatically define `test_...` macros for testing purposes.

## Target-specific options

**-m32** `flag`

Generate 32-bit code (defer to i386 cross compiler if needed).

**-m64** `flag`

Generate 64-bit code (defer to x86\_64 cross compiler if needed).

```bash theme={null}
tcc -m32 source.c -o program32
```

**-mms-bitfields** `flag`

Use Microsoft Visual C++ algorithm for bitfield layout instead of GCC's algorithm.

**-mfloat-abi** `string`

Select floating-point ABI on ARM. Values: `softfp` or `hard`.

**-mno-sse** `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:

```bash theme={null}
-arch -C --param -pedantic -pipe -s -traditional
```

> [!TIP]
>
> Use `-Wunsupported` to get warnings about ignored GCC features and options.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.