--- id: pcpp version: "1.30" license: BSD license_treatment: permissive maintenance: aging --- # pcpp — A C99 preprocessor written in pure Python License: permissive · Maintenance: aging · Downloads: 791.6K/mo ## What it is and what it does pcpp is a C99 preprocessor written entirely in Python, designed to handle C and C++ preprocessing tasks at build or packaging time. It processes #include directives, macro definitions, and conditional compilation blocks, and can output either fully expanded code or partially preprocessed code with selective pass-through of certain directives. The package is useful for collapsing header-only C++ libraries into single files, preparing code for documentation tools like Doxygen, or integrating preprocessing into Python-based build pipelines. The preprocessor passes a modified mcpp unit test suite and handles complex recursive macro expansions that conform to C99 standards. It offers both a Python API (by subclassing the Preprocessor class) and a command-line tool that mimics conventional C preprocessors. Partial preprocessing modes allow fine-grained control over which directives are executed versus passed through, making it flexible for different build scenarios. Use it for: - Collapse header-only C++ template libraries into single-file includes for easier distribution - Preprocess C code before feeding it to documentation generators like Doxygen that have limited preprocessor capabilities - Expand macros and resolve conditional compilation in C source files as part of a Python-based build system - Benchmark and analyze header file complexity to identify optimization opportunities in build times - Selectively expand nested includes while preserving system header references in generated output ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pure Python implementation of a C99 preprocessor that can preprocess C/C++ header files and source code, available both as a Python module and command-line tool. Yes, if you need C99 preprocessing in a Python environment. The package is stable and dependency-free, making it easy to integrate. However, the 2021 release date and aging maintenance status mean it may not track the latest C standards or receive active bug fixes—suitable for established workflows but verify compatibility with your specific C/C++ code patterns first. ## Install pip install pcpp uv add pcpp poetry add pcpp ## Installing pcpp Before you install: Low install friction with no runtime dependencies. Package is in production/stable status but aging—last release was in 2021, though the repository remains active with recent commits. License in practice: BSD license (permissive) means you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions. Quickstart: pip install pcpp from pcpp.preprocessor import Preprocessor prep = Preprocessor() prep.parse(open('input.h').read()) print(prep.write()) Verify before relying: - Whether Python 2 support (listed in classifiers) is actively maintained given the 2021 release date - Current performance characteristics under modern Python versions compared to the stated 0.84x–2.62x range under PyPy ## Package facts - License: BSD (permissive) - Python support: unspecified - Install friction: low - Maintenance: aging - Downloads: 791.6K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags C preprocessor Python, C99 preprocessor, header file preprocessing, C macro expansion, build stage preprocessing, single file includes, macro evaluation, c-preprocessing, build-automation, header-processing [View on SkillFed](https://skillfed.io/packages/pcpp) · [View on PyPI](https://pypi.org/project/pcpp/)