ccpp — a tiny toy C preprocessor
Features (initial):
- Supports simple object-like
#define NAME VALUEmacros (no args) - Replaces identifiers in code, skipping string literals and comments
- Reads from a file path or stdin; writes to stdout
Usage:
- Build:
make -C ccpp - Test:
make -C ccpp test - Run:
./ccpp/ccpp [input.c] > output.c
Header scans:
- Linux (curated):
make -C ccpp test-linux-core-headers - Linux (broad):
make -C ccpp test-linux-headers(see Makefile for variants) - macOS (C/Unix only):
make -C ccpp test-macos-c-unix-headers
Limitations (by design for now):
- No
#include, conditionals, or function-like macros - No macro redefinition/undef tracking beyond last definition wins
- Block comments are skipped at a basic level; nested comments not supported
Pragmas:
#pragma onceis honored internally to avoid duplicate includes.- Other
#pragmadirectives are suppressed in output by default. SetCCPP_PRESERVE_PRAGMAS=1to pass them through unchanged.