Open-Source Wikis

/

Zig

/

Applications

/

aro (C frontend)

ziglang/zig

aro (C frontend)

Active contributors: vexu, andrewrk

Purpose

lib/compiler/aro/ is the bundled Aro C frontend — a Zig-language C tokenizer, preprocessor, and parser. It is compiled into the zig binary and used by zig translate-c to convert C code into Zig, plus by other compiler paths that need to preprocess or parse C without invoking clang.

Aro is upstream's project; the copy here vendors the parts the Zig compiler depends on.

Directory layout

lib/compiler/aro/
├── aro.zig                  # public API
├── aro/                     # core implementation
├── assembly_backend.zig     # inline assembly support
├── assembly_backend/        # arch-specific bits
├── backend.zig              # abstract backend trait
├── backend/                 # backend implementations
├── include/                 # bundled C headers Aro ships
└── main.zig                 # standalone CLI (when run as a tool)

How the compiler uses it

  • zig translate-clib/compiler/translate-c/ consumes Aro's AST and lowers it to Zig.
  • @cImport — the Sema-time C ingestion path uses Aro's preprocessor and parser to turn a synthetic C translation unit into a Zig module.
  • zig cc / zig c++ — when delegating to clang, Aro is not in the hot path. It is, however, used in a few places where the Zig compiler itself needs to read C declarations without spawning clang.

What Aro covers

  • Tokenization, preprocessing, and parsing of standards-conformant C up to C23 (subject to upstream Aro's own progress).
  • A typed AST over which lib/compiler/translate-c/ walks.
  • An assembly-backend abstraction so it can emit and validate inline assembly for the host arch.
  • Bundled headers under lib/compiler/aro/include/ for self-contained operation.

Standalone use

lib/compiler/aro/main.zig is the entry point when Aro is built as its own executable (useful for development). The build graph in build.zig exposes it as one of the test targets.

Key source files

File Purpose
lib/compiler/aro/aro.zig Public Aro API consumed by translate-c and @cImport.
lib/compiler/aro/aro/ Tokenizer, preprocessor, parser, AST.
lib/compiler/aro/assembly_backend.zig Inline assembly support.
lib/compiler/aro/backend.zig Backend abstraction.
lib/compiler/aro/include/ Bundled C headers.
lib/compiler/aro/main.zig Standalone CLI.
lib/compiler/translate-c/ Consumes Aro to emit Zig.

See translate-c for the user-facing tool that turns Aro's output into Zig source.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

aro (C frontend) – Zig wiki | Factory