title: How do I use C++ modules in Clang?
body: <p>Modules are an alternative to #includes. <a href="https://botondballo.wordpress.com/2014/07/17/trip-report-c-standards-committee-meeting-in-rapperswil-june-2014/" rel="noreferrer">Clang has a complete implementation for C++</a>. How would I go about if I wanted to use modules using Clang now?</p>
  
  <hr>
  
  <p>Using</p>
  
  <pre><code>import std.io;
  </code></pre>
  
  <p>in a C++ source file does not work (compile) yet, as the specification for modules (which includes syntax) isn't final.</p>
  
  <hr>
  
  <p>The <a href="http://clang.llvm.org/docs/Modules.html#includes-as-imports" rel="noreferrer">Clang documentation</a> states that, when passing the <code>-fmodules</code> flag, #includes will be rewritten to their appropriate imports. However, checking the preprocessor suggests otherwise (test.cpp only contains <code>#include &lt;stdio.h&gt;</code> and an empty main):</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ clang++-3.5 -fmodules -E test.cpp -o test
  $ grep " printf " test
  extern int printf (const char *__restrict __format, ...);
  </code></pre>
  
  <p>Furthermore, compiling this test file with <code>-fmodules</code> vs no flags at all produces the same object file.</p>
  
  <p>What am I doing wrong?</p>