... a C++ preprocessor library for Python

About CppPre

CppPre is an implementation of a C++ preprocessor that conforms to the C++ Standard 2003 a.k.a. C++03. It requires Python version 2.4 or later [*] , and features the following:

  • A simple-to-use iterator interface;
  • Full error reporting of all preprocessor-related defects in the source code;
  • Each preprocessing token output by the preprocessor includes information on the file and location within that file where it originated from;
  • A callback function can be installed to allow you to choose whether or not each file included in the translation unit should actually be included;
  • A callback function can be installed to allow you to view each define statement in the translation unit as it is being preprocessed;
  • Support for extensions to the C++ language, including dollar signs in identifiers and special macros like __COUNTER__.

The primary limitation of CppPre is its performance: it cannot compete for speed with the preprocessors included in C++ compilers. Rather, it is intended that CppPre be used for tasks where execution time is not critical.

[*] CppPre may in fact run on earlier versions of Python than version 2.4, but this has not yet been confirmed.