I've never actually tried this myself, but just an idea: wouldn't it be helpful if you, first, let C/C++ preprocessor do the job, and apply C->Pascal translator on the result of it? Of course, you will loose any important #ifdef's (for example those conserning OS or CPU used), but you wouldn't need to worry about macro-hell. Looking at your example, I'm pretty sure it would do the job