Opening Up The C/C++ Preprocessor Black Box

László Vidács and Árpád Beszédes
File inclusion, conditional compilation and macro processing has made the preprocessor a powerful tool for programmers. Preprocessor directives are extensively used in C/C++ programs and have various purposes. However, program code with lots of directives often causes problems in program understanding and maintenance. The main source of the problem is the difference between the code that the programmer sees and the preprocessed code that the compiler is given. We designed a Preprocessor Schema and implemented a preprocessor which produces both preprocessed (.i) files and schema instances. The Schema is general purpose and its instances model both the whole preprocessed compilation unit and the transformations made by the preprocessor. Therefore it facilitates program comprehension and tool interoperability.

Keywords: C, C++, preprocessor, program understanding, program model, Preprocessor Schema, tool interoperability