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 for machines with little memory. Every page below has a worked example that compiles and runs. The programs live in the repository and a script builds them, so the code blocks match what the compiler does.
Where to start
Section titled “Where to start”To read the reference in 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:
callback, target/action, and why a callback needs no context pointer. - Blocks:
{ … }closures that capture their surrounding scope, and how they pair with bound methods. - 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, open the page you need from the sidebar.
Things that differ from C
Section titled “Things that differ from C”- 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 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 instead of 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 are in Compiler usage. They shape the output but are not part of the language. Start with Install.
- Standard library classes (
Stdio,Math,Heap,Assert, …) are 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.