Skip to main content

Quick start

This guide will get you up and running with TinyCC in just a few steps. You’ll learn how to compile and run C programs using TCC’s unique direct execution feature.
Before starting, make sure you have installed TinyCC on your system.

Your first TCC program

Let’s create and run a simple “Hello World” program using TCC.
1

Create a C source file

Create a file named hello.c with the following content:
hello.c
2

Compile and run directly

TCC’s killer feature is the ability to compile and execute in one step:
Output:
The -run option compiles the code in memory and executes it immediately without creating an executable file. This is perfect for quick testing and scripting!
3

Create an executable (optional)

If you want to create a standalone executable:
This creates a binary file named hello that you can run anytime.

TCC as a C script interpreter

One of TCC’s most powerful features is C scripting support. You can run C code like a shell script!
1

Create a C script

Create a file named hello_script.c:
hello_script.c
The first line is a shebang that tells your shell to use TCC to run the file.
2

Make it executable

Set the execute permission:
3

Run it directly

Now you can run it like any shell script:
Output:
If TCC is installed in a different location on your system, adjust the shebang path accordingly. Use which tcc to find the correct path.

Working with command line arguments

C scripts can accept command line arguments just like any other program:
args_demo.c
Output:

Compiling multiple files

TCC can compile and link multiple C files together:
1

Create a utility module

Create utils.c:
utils.c
And its header utils.h:
utils.h
2

Create the main program

Create main.c:
main.c
3

Compile and run

Compile both files together:
Output:

Using TinyCC’s built-in library

TCC includes a minimal library tcclib.h that’s perfect for small programs or systems without standard headers:
minimal.c
Using <tcclib.h> instead of <stdio.h> results in faster compilation times. It’s especially useful for floppy disk or embedded environments where space is limited.

Compiling from stdin

TCC can read and compile C code from standard input, which is great for one-liners and testing:
Output:
This technique is useful for quick experiments and integrating with shell pipelines.

Common compilation patterns

Comparing TCC with GCC

Here’s how TCC commands compare to GCC:
TCC optimizes for compilation speed, not runtime performance. For production code where runtime speed matters, consider using GCC or Clang with optimization flags like -O2 or -O3.

Benchmarking compilation speed

See the difference in compilation speed:
TCC typically compiles 9-10 times faster than GCC with -O0 (no optimization).

Next steps

Command line reference

Learn about all TCC command line options and flags

C scripting guide

Master advanced C scripting techniques with TCC

libtcc API

Use TCC as a library for dynamic code generation

Features

Explore TCC features and capabilities
Try using TCC for your daily C development tasks. The instant compilation feedback makes it great for learning C, testing algorithms, and rapid prototyping.