Understanding code containing preprocessor constructs

Understanding, debugging, and maintaining software is a costly and difficult task. The difficulties are exacerbated in programs written to take advantage of preprocessing facilities. This paper examines problems associated with source code containing preprocessor constructs-i.e. included files, conditional compilation and macros. We define the useful mappings from tokens in the preprocessor's output to the source file(s), and propose that by capturing these correspondences, an internal program representation can be built which allows for the use of maintenance techniques including program slicing, ripple analysis and dicing. The method presented is generic; to illustrate that the technique is feasible, we discuss ANSI C preprocessor constructs-in particular, macro substitution-and explain the modus developed to handle them in GHINSU-an integrated maintenance environment for ANSI C programs.<<ETX>>