Language reference
xcc is a small, statically-typed language with C-family syntax, ObjC-like classes and protocols, and a focus on producing dense code on machines that cannot afford waste. Every page below carries a worked example that compiles and runs — the programs live in the repository and are built by a script, so a code block here cannot drift from what the compiler actually does.
Where to start
Section titled “Where to start”If you’re reading top-to-bottom, this is the recommended order:
- Lexical structure — comments, identifiers, numeric and string literals, reserved words.
- Preprocessor —
#include/#import,#define, conditional compilation. - Types — the fixed-width scalars including
i64/u64, structs, enums, pointers, arrays, inference, casting. - Operators — the full precedence table, including the rotate (
<::>) and byte-extract (<>>>>>>) operators. - Statements & control flow — declaration modifiers,
if,switch, the twoforloops,while,defer,:unroll. - Functions — declarations, multiple return values, varargs, overloading, function annotations.
- Classes — heap and stack allocation, methods, properties,
init/dealloc. - Inheritance & protocols — single inheritance, virtual dispatch, downcasts (
(Dog*)aand the failable(Dog* ?)a), protocols and optional methods. - Bound methods & callbacks —
^, target/action, and why a callback needs no context pointer. - Errors — the
throwseffect,throw, typed and untypedcatcharms, theErrorprotocol. - Heap, ARC & weak refs —
new/delete, automatic reference counting,weak:references, manual-farc=offmode. - Collections & strings —
Array<T>,Map<V>,Set<T>,String, and how element types are checked then erased. - Threading —
Thread,Mutex,Atomic,Pool, and the automatic atomic-refcount decision. Native targets only. - Modules & shared libraries —
--emit-lib,#import <Lib>, what crosses a library boundary, andexternglobals. - Inline assembly —
asm { … }blocks, byte-extract operators, reaching xcc variables, theclobbersannotation.
For day-to-day reference, jump straight to the page you need from the sidebar.
Things that differ from C
Section titled “Things that differ from C”Worth knowing before you write the first program:
- The pointer sigil binds to the type.
u8* a, b;declares two pointers, not a pointer and an integer. - No promotion to
int. Same-width arithmetic stays at that width, sou8 + u8wraps at 8 bits. Only genuinely mixed-width operands widen. printfwidths are explicit.%dis 16-bit,%ldis 32-bit and%lldis 64-bit; all three are signed, so use the%ufamily (%u,%lu,%llu) for unsigned. The compiler checks the format string against the argument types — and widens a conversion whose argument is statically wider, so%don ani64prints the whole value rather than truncating.- Source files are
.xc
What’s not on these pages
Section titled “What’s not on these pages”- Compiler flags, optimisation levels, memory-model selection live in Compiler usage — they shape the output but are not part of the language. Start with Install.
- Standard library classes (
Stdio,Math,Heap,Assert, …) live in the Standard library reference. - Memory-model internals (the two bank windows, the hardware stack) are summarised where they affect semantics; the full map is in Compiler usage → Memory models.