Includium
A complete C preprocessor implementation in Rust.
API Documentation | CLI Documentation | Changelog
includium is a robust, well-tested C preprocessor that can process C/C++ source code with macros, conditional compilation, and includes. It supports target-specific preprocessing for different operating systems and compilers.
This repository contains both the core library and a command-line interface (includium-cli).
Features
| Feature | Description |
|---|---|
| Macro Expansion | Supports both object-like and function-like macros |
| Conditional Compilation | Full support for #ifdef, #ifndef, #if, #else, #elif, #endif |
| Include Processing | Handles file inclusion with custom resolvers |
| Target-Specific Definitions | Pre-configured macros for Linux, Windows, and macOS |
| Compiler Support | Mock definitions for GCC, Clang, and MSVC |
| C FFI | Integration capabilities for use with other languages and ecosystems |
Supported Platforms
| OS | Compilers | Status |
|---|---|---|
| Linux | GCC, Clang | ✅ Fully supported |
| Windows | MSVC | ✅ Fully supported |
| macOS | Clang | ✅ Fully supported |
Table of Contents
Installation
Add includium to your Cargo.toml using
or manually by editing Cargo.toml:
[]
= "0.1.0"
Usage
As a Library
[!WARNING] Compiler-specific macro definitions are approximations. While they match common behavior for GCC, Clang, and MSVC, edge cases may differ from real toolchains.
use ;
As a CLI
The includium-cli package provides a command-line interface for the C preprocessor. See the CLI documentation for detailed usage instructions.
Basic installation:
Basic usage:
# Preprocess a file
# Cross-compile for Windows
Development
Just Tasks
This project uses Just for task automation. Available tasks:
| Task | Description | Arguments |
|---|---|---|
build |
Build the workspace (library + CLI) | None |
build-release |
Build in release mode | None |
test |
Run all tests | None |
check |
Run all checks (format, lint, test) | None |
run |
Run the CLI with arguments | --help |
run-release |
Run the CLI in release mode | input.c -o output.i |
install |
Install the CLI locally | None |
clean |
Clean build artifacts | None |
docs |
Generate documentation | None |
Building from Source
-
Clone the repository:
-
Build the workspace:
-
Run tests:
Advanced Usage
[!NOTE] This section is intended for advanced users who need custom include resolution or fine-grained control over diagnostics and preprocessing behavior.
Custom Include Resolvers
use Preprocessor;
let mut preprocessor = new
.with_include_resolver;
#warning Handling
use PreprocessorConfig;
use Rc;
let warning_handler = new;
let config = for_linux
.with_warning_handler;
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Roadmap
- CLI (includium-cli)
- Integration tests
- Benchmarks with
cargo bench - CI with cross-platform tests for multiple compilers
Reporting Issues
If you find a bug or have a feature request, please open an issue with:
- A clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Platform and compiler information
License
This project is licensed under the Mozilla Public License Version 2.0. See the LICENSE file for details.