title: stdin as input file for MSVC
body: <p>I have a custom tool that I want to run as part of the compile process, between the preprocessing and compiling. For GCC, I do:</p>
  
  <pre><code>gcc [options] -E source.c | mytool | gcc [options] -c source.o -xc -
  </code></pre>
  
  <p>However, I haven't figured out how to do something similar for MSVC. Currently I have</p>
  
  <pre><code>cl.exe [options] /EP source.c | mytool.exe &gt; temp.c
  cl.exe [options] /c temp.c
  </code></pre>
  
  <p>The problem here is that for every source file (thousands), I have an additional disk write/read cycle. Additionally, when MSVC outputs the .i files, they tend to get really large. Over 10MB large. So the 10MB disk I/O per file piles up really quickly.</p>
  
  <p>So, my questions:</p>
  
  <p>1) Is it possible to get cl.exe to read treat stdin as an input file?</p>
  
  <p>2) If not, is it possible to create a memory mapped file it can read from?</p>
  
  <p>3) Is there a better way to do this?</p>
  
  <p>And no, "get an SSD" and "don't use MSVC" are not valid answers, sorry. </p>
  
  <p>Related (but not solving the speed issue)</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/6099415/any-way-to-parse-preprocessed-source-through-external-tool-before-it-compiles?rq=1">Any way to parse preprocessed source through external tool before it compiles?</a></li>
  <li><a href="https://stackoverflow.com/questions/4757231/how-can-i-run-the-msvc-preprocessor-and-compiler-in-two-separate-steps?rq=1">How can I run the MSVC preprocessor and compiler in two separate steps?</a></li>
  </ul>