cppi
« Back to VersTracker
Description:
Indent C preprocessor directives to reflect their nesting
Type: Formula  |  Latest Version: 1.18@0  |  Tracked Since: Dec 17, 2025
Links: Homepage  |  formulae.brew.sh
Category: Developer tools
Tags: c-preprocessor code-formatting c c++ developer-tools cli
Install: brew install cppi
About:
cppi is a command-line utility that automatically formats C preprocessor directives by indenting them according to their conditional nesting levels. This transforms often unreadable preprocessor code into a visually structured format that mirrors the logical structure of the code. It is invaluable for developers needing to quickly understand complex conditional compilation blocks in legacy or large C/C++ projects.
Key Features:
  • Automatically indents #if, #else, #elif, #endif directives
  • Preserves code logic while improving visual hierarchy
  • Supports both in-place file modification and standard output
  • Handles complex nested conditional blocks reliably
Use Cases:
  • Refactoring and understanding legacy C/C++ codebases with extensive preprocessor usage
  • Standardizing formatting of preprocessor directives in a project
  • Auditing conditional compilation paths for debugging or porting
Alternatives:
  • clang-format – A full-featured C/C++ code formatter that can handle some preprocessor formatting but is much heavier and focuses on the entire codebase.
  • unifdef – Focuses on removing or evaluating conditional blocks rather than reformatting them for readability.
License: GPL-3.0-or-later
Bottles available for: arm64_tahoe, arm64_sequoia, arm64_sonoma, arm64_ventura, arm64_monterey, arm64_big_sur, sonoma, ventura, monterey, big_sur, catalina, arm64_linux, x86_64_linux
Version History
Detected Version Rev Change Commit
Sep 14, 2025 2:45am 0 VERSION_BUMP ad7fd977