Embracing the C preprocessor during refactoring
Version of Record online: 26 JUN 2013
Copyright © 2013 John Wiley & Sons, Ltd.
Journal of Software: Evolution and Process
Volume 25, Issue 12, pages 1285–1304, December 2013
How to Cite
Garrido, A. and Johnson, R. (2013), Embracing the C preprocessor during refactoring. J. Softw. Evol. and Proc., 25: 1285–1304. doi: 10.1002/smr.1603
- Issue online: 11 DEC 2013
- Version of Record online: 26 JUN 2013
- Manuscript Accepted: 15 MAY 2013
- Manuscript Revised: 24 FEB 2013
- Manuscript Received: 23 FEB 2012
- preprocessor directives;
- code analysis;
- software maintenance
C preprocessor directives are heavily used in C programs because they provide useful and even necessary additions to the C language. However, they are usually executed and discarded before any analysis is applied on C programs. In refactoring, preprocessor directives must be preserved through the whole process of parsing, analysis and transformation to retain editable yet correct source code. We propose a new preprocessing approach and special program representations that allow a program to be analyzed and transformed without losing its preprocessor directives, but treating them as first-class program entities. These representations are essential for a correct refactoring tool. We also describe the challenges that preprocessor directives bring to refactoring and how the program representations that we propose solve those challenges. Finally, we give details of two refactorings and present some case studies with our successfully applied solution. Copyright © 2013 John Wiley & Sons, Ltd.