In the future: I did not find a way to trick cl.exe into reading from memory instead of a disk.
However, I managed to speed up the process to an acceptable speed, using GNU CPP for the first stage, then cl.exe only for compilation. So:
cpp.exe [options] source.c | mytool.exe > temp.c cl.exe [options] temp.c
cpp.exe creates a file 5-10 times smaller than cl.exe /E The trick is only to define _MSC_VER and similar instead of __GNUC__ . I did this using the -undef option to get rid of everything, then define the MSFT-specific manually. I can learn to use clang as CPP since it can mimic MSVC.
CPP leaves the #pragma intact, so there are no compatibility issues there.
Now I have reached a performance point when the occurrence of a process has a significant impact on the overall build time, so I am looking for compilation of the preprocessor in mytool.exe .
source share