
On 6/10/2015, at 11:59 am, Doug McIlroy
Another trick is to use plain if rather than #if or #ifdef, and let the compiler optimize away the unwanted side of the branch.
The University of Edinburgh had their own systems implementation language, IMP. Fortran -> Algol 60 -> Atlas Autocode -> IMP. It was no surprise to find that %if <constant condition> %then <true part> %else <false part> eliminated whichever branch would not be executed. But it was astonishing to discover that %if <constant condition> %then %start <declarations T> %finish %else %start <declarations F> %finish would only process the declarations in the chosen part. If you want to eliminate the preprocessor, you have got to handle conditional declarations. Even IMP did not handle %record %format table ( ... %if keeping statistics %then %start %integer accesses, hits, misses, %endif ...) which is something that a preprocessor can handle.