Sciweavers

KBSE
2009
IEEE

Static Validation of C Preprocessor Macros

13 years 11 months ago
Static Validation of C Preprocessor Macros
—The widely used C preprocessor (CPP) is generally considered a source of difficulty for understanding and maintaining C/C++ programs. The main reason for this difficulty is CPP’s purely lexical semantics, i.e., its treatment of both input and output as token streams. This can easily lead to errors that are difficult to diagnose, and it has been estimated that up to 20% of all macros are erroneous. To reduce such errors, more restrictive, replacement languages for CPP have been proposed to limit expanded macros to be valid C syntactic units. However, there is no practical tool that can effectively validate CPP macros in legacy applications. In this paper, we introduce a novel, general characterization of inconsistent macro usage as a strong indicator of macro errors. Our key insight is that all applications of the same macro should behave similarly. In particular, we map each macro call c in a source file f to c’s normalized syntactic constructs within ract syntax tree (AST) ...
Andreas Saebjoernsen, Lingxiao Jiang, Daniel J. Qu
Added 21 May 2010
Updated 21 May 2010
Type Conference
Year 2009
Where KBSE
Authors Andreas Saebjoernsen, Lingxiao Jiang, Daniel J. Quinlan, Zhendong Su
Comments (0)