Skip to content

Quick Start

Create and run your first FastC project in under 5 minutes.

Create a New Project

Use the fastc new command to create a project:

fastc new hello_world
cd hello_world

This creates the following structure:

hello_world/
├── fastc.toml      # Project configuration
├── Makefile        # Build script
├── src/
│   └── main.fc     # Main source file
└── build/          # Output directory (created on build)

Examine the Code

Open src/main.fc:

// A simple FastC program
fn main() -> i32 {
    return 0;
}

Build and Run

The easiest way to build and run:

fastc run

Output:

No dependencies to fetch.
Compiling: /path/to/hello_world/src/main.fc
  Wrote: build/main.c
  Wrote: build/main.h
FastC compilation complete.
Compiling C code with cc...
  Wrote: build/main
C compilation complete.
Running: build/main
---
---
Program exited with code: 0

Add Some Code

Let's make it more interesting. Edit src/main.fc:

fn add(a: i32, b: i32) -> i32 {
    return a + b;
}

fn main() -> i32 {
    let x: i32 = 10;
    let y: i32 = 20;
    let sum: i32 = add(x, y);
    return sum;
}

Run again:

fastc run

The exit code will be 30 (10 + 20).

Type Checking Only

To check your code without compiling:

fastc check src/main.fc

Output: No errors found.

View Generated C Code

To see the generated C code:

fastc compile src/main.fc

This outputs to stdout:

/* Generated by fastc - do not edit */

#include "fastc_runtime.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

int32_t add(int32_t a, int32_t b);
int32_t main(void);

int32_t add(int32_t a, int32_t b) {
    int32_t __tmp0;
    if (__builtin_add_overflow(a, b, (&__tmp0))) {
        fc_trap();
    }
    return __tmp0;
}

int32_t main(void) {
    int32_t x = 10;
    int32_t y = 20;
    int32_t sum = add(x, y);
    return sum;
}

Notice how FastC automatically adds overflow checking for safe arithmetic!

Project Configuration

The fastc.toml file configures your project:

[package]
name = "hello_world"
version = "0.1.0"
type = "binary"

[build]
include_dirs = []
link_libs = []

[dependencies]

Release Builds

For optimized builds:

fastc run --release

This passes -O2 to the C compiler and disables debug info.

Using a Different Compiler

To use clang instead of the default:

fastc run --compiler clang

Or add extra flags:

fastc run --cflags "-Wall -Wextra"

What's Next?