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. From a native host, cpc cross-compiles static libraries and headers for iOS, Android, and ESP32 with --target; the WebAssembly path is provided by cpc-wasm. See Platforms and targets. Front-end commands such as cpc check, cpc fmt, cpc lsp, and cpc query do not invoke clang.
Facet applications are supported through facet_runtime with facet_appkit on macOS, facet_uikit on iOS, facet_android on Android, facet_gtk on Linux, and facet_win32 on Windows.
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 and src/. Installed packages resolve from a local vendor/ override first and then the per-user package store:
hello/
├── Cplus.toml
└── src/main.cplus
Cplus.toml:
[package]
name = "hello"
version = "0.0.1"
edition = "2026"
[dependencies]
stdlib = "*"
src/main.cplus is the default application entry. To use another file, set entry = "path/to/file.cplus" under [package]. The removed [[bin]] and [lib] tables are not accepted in 0.0.28; C-facing library products use [library].
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. cpc init hello creates this project shape and an embedded agent reference.
Next
Continue with Ownership, the part of C+ that differs most from C.