MLM - multi-line macros for cpp


MLM is a patch to gnu cpp version 2.7.2 that adds multi-line cpp directives. Macros can be defined that extend over several lines, without placing a backslash at the end of each line, as is normally required by cpp. A detailed description of the syntax is available. MLM was written by Andrew Myers.

An even more useful feature of the extended cpp is that the compiler reports any errors at the correct place inside the macro definition rather than at the point where the macro was invoked—even when the macro is defined in a different file from the point of invocation.

For example, the following multiline macro can be used to swap two variables x and y of type T:

#begin define swap(x,y,T)
do {
    T temp = x;
    x = y;
    y = temp;
} while (0)
#end /* swap */

The extended cpp is completely backwards compatible with vanilla cpp, adding only the new #begin and #end directives.

Download MLM 1.0

The MLM package contains the following three useful programs:

For help in compiling or using MLM, or to receive announcements of future updates to MLM, please send mail to the address below.


Andrew Myers