Preprocessing C++ : Substitution and Composition

Edward D. Willink and Vyacheslav B. Muchnick.

Problems with the lexical substitution mechanism of the C preprocessor are well known. We resolve these problems with a new syntax-based substitution mechanism for C++ based on meta-variables and meta-functions. Implementation of these meta-concepts in a C++ style leads naturally to meta-expressions and then meta-statements and a generalisation of C++ syntax. We show how meta-compilation renders the C preprocessor redundant, and offers a more intuitive and powerful programming language in which pattern solutions can be provided and Aspect-Oriented programming practiced. In a companion paper [21] we go one stage further, putting the concepts together in the context of meta-classes where meta-programming and reflection are supported at compile-time.

PostScript of full paper. 163kB.

PDF of full paper. 43kB.

FOG home page.

Ed Willink's home page.


Last updated 03 April 2001.