C+
Introduction · View as Markdown

Getting started

C+ has two modes: single-file, where one file compiles on its own with built-in helpers, and project, where a Cplus.toml manifest pulls in imports. Pick one mode per program.

Install

On macOS M-series, install with Homebrew:

brew install netdur/cplus/cplus
cpc --version

This installs prebuilt cpc, cpc-lsp, and cpc-bindgen with no Rust toolchain and no compile step; update later with brew upgrade cplus. The one external requirement is a C toolchain (clang), used to assemble and link the native binary. On macOS it comes from the Xcode Command Line Tools:

xcode-select --install

Linux x86-64 (.deb) and Windows x86-64 (.zip) builds are published on the GitHub releases page (ARM Linux and ARM Windows hosts are planned). From any host, cpc cross-compiles to iOS, Android, and the ESP32 with --target — see Targets & cross-compilation. The front-end commands (cpc check, cpc fmt, cpc lsp, cpc query) need no external tools at all.

GUI packages are separate from the compiler/toolchain targets. Native GUI support is available today through appkit (macOS) and uikit (iOS). Linux GTK+ and Windows Win32 backends are planned.

Single-file mode

The smallest complete program:

fn main() -> i32 {
    #println("hello, world");
    return 0;
}

Build and run it:

cpc hello.cplus -o hello
./hello

In single-file mode println is a built-in intrinsic, so there is no import. It accepts an i32 or a str.

Project mode

A project is a directory with a manifest, a src/, and its dependencies:

hello/
├── Cplus.toml
├── vendor/stdlib   (the standard library)
└── src/main.cplus

Cplus.toml:

[package]
name    = "hello"
version = "0.0.1"
edition = "2026"

[[bin]]
name = "hello"
path = "src/main.cplus"

[dependencies]
stdlib = "*"

src/main.cplus:

import "stdlib/io" as io;

fn main() -> i32 {
    io::println("hello from a project");
    return 0;
}

Build and run:

cpc build
./target/debug/hello

Do not mix the two modes. In a project, use io::println from the standard library, not the intrinsic #println.

Next

Continue with Ownership, the part of C+ that differs most from C.