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:
- gcc-2.7.2-mlm.diff
This file is a patch to gcc 2.7.2, adding MLM functionality to
the C preprocessor. It can probably be applied to
other versions of the gcc source.
To apply the patch, use Larry Wall's "patch" program.
- no_mlm
This perl script edits one or more files, replacing any MLM macros
found by generic cpp macros. This functionality is useful if you
need to ship your programs to people lacking MLM.
- bsl
This script can be used to add or remove backslashes from a range of
lines. It is designed to be used through the vi "!" command.
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