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
#include <stdio.h>

int main()
{
    printf("Hello World\n");
    return 0;
}
2

Compile and run directly

TCC’s killer feature is the ability to compile and execute in one step:
tcc -run hello.c
Output:
Hello World
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:
tcc hello.c -o hello
./hello
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
#!/usr/local/bin/tcc -run
#include <stdio.h>

int main()
{
    printf("Hello from a C script!\n");
    return 0;
}
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:
chmod +x hello_script.c
3

Run it directly

Now you can run it like any shell script:
./hello_script.c
Output:
Hello from a C script!
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
#!/usr/local/bin/tcc -run
#include <stdio.h>

int main(int argc, char **argv)
{
    printf("Program name: %s\n", argv[0]);
    printf("Number of arguments: %d\n\n", argc - 1);
    
    for (int i = 1; i < argc; i++) {
        printf("Argument %d: %s\n", i, argv[i]);
    }
    
    return 0;
}
tcc -run args_demo.c hello world 123
Output:
Program name: args_demo.c
Number of arguments: 3

Argument 1: hello
Argument 2: world
Argument 3: 123

Compiling multiple files

TCC can compile and link multiple C files together:
1

Create a utility module

Create utils.c:
utils.c
#include <stdio.h>

void greet(const char *name)
{
    printf("Hello, %s!\n", name);
}
And its header utils.h:
utils.h
#ifndef UTILS_H
#define UTILS_H

void greet(const char *name);

#endif
2

Create the main program

Create main.c:
main.c
#include "utils.h"

int main()
{
    greet("TinyCC");
    return 0;
}
3

Compile and run

Compile both files together:
tcc -run main.c utils.c
Output:
Hello, TinyCC!

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
#!/usr/local/bin/tcc -run
#include <tcclib.h>

int main()
{
    printf("Hello World\n");
    return 0;
}
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:
echo 'main(){puts("hello");}' | tcc -run -
Output:
hello
This technique is useful for quick experiments and integrating with shell pipelines.

Common compilation patterns

tcc -run program.c

Comparing TCC with GCC

Here’s how TCC commands compare to GCC:
TaskTCCGCC
Compile and runtcc -run hello.cgcc hello.c -o hello && ./hello
Create executabletcc hello.c -o hellogcc hello.c -o hello
Compile to objecttcc -c hello.cgcc -c hello.c
Show versiontcc -vgcc --version
Verbose outputtcc -vvgcc -v
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 with benchmark
tcc -bench hello.c -o hello

# Compare with GCC
time gcc -O0 hello.c -o hello_gcc
time tcc hello.c -o hello_tcc
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.

Build docs developers (and LLMs) love