Preprocessors - Folding


Since the early days of programming, preprocessors have been used to increase the expressiveness of programming languages. As a prominent example, the C Preprocessor (cpp) even allows low level configuration management through conditional compilation. But preprocessors significantly complicate the task of program understanding because ''what the user sees is not what the compiler gets''. There is a need for bridging the gap between preprocessor input and preprocessor output.

In the reengineering research community, the preprocessor problem is well known. But the majority of reengineering tools for programming languages with preprocessors ignore this problem. Some simply disregard the preprocessor and try to analyze the original source code, while others start work after the preprocessor has done its job.

As part of the GUPRO project, we have developed a specialized C Preprocessor, the GUPRO C Preprocessor (gcpp). This is an implementation of a standard C preprocessor with additional capabilities. The main difference from the standard cpp's is that gcpp keeps track of all macro expansions and builds a data structure called a fold graph to provide folding information for the parser and the GUPRO source code browser.

Our research on preprocessors in reengineering has produced some promising results. Using three programs, the GUPRO C Preprocessor, the GUPRO C parser and the GUPRO graphical user interface, we have combined a precise fact extractor with additional information generated by the preprocessor. This enables source code browsing at any level between the original source code (preprocessor input) and the preprocessor output.

Our current research concentrates on further narrowing the preprocessor gap by conveying more semantic information from the preprocessor to the fact extractor. This information contains annotations such as Constants, Inline Functions, and Renaming, for preprocessor macros.




Riediger, Volker (2004): Die Präprozessor-Problematik im Reverse Engineering und beim Programmverstehen. Universität Koblenz-Landau.


Kullbach, Bernt; Riediger, Volker (2001): Folding: An Approach to Enable Program Understanding of Preprocessed Languages. In: Proceedings of the 8th Working Conference on Reverse Engineering (WCRE 2001). Los Alamitos: IEEE Computer Society. S. 3-12.

Kullbach, Bernt; Riediger, Volker (2001): Folding: An Approach to Enable Program Understanding of Preprocessed Languages. Institut für Informatik, Universität Koblenz-Landau. Nr. 7/01. Fachberichte Informatik.

Riediger, Volker (2001): The GUPRO C Preprocessor. Koblenz: Institut für Softwaretechnik, Universität Koblenz- Landau. Nr. 4/01. Projektbericht.