title: Import text file into raw string literal at compile time
body: <p>I have a text file containing resources my application needs. The file contains arbitrary plain text, <em>not</em> C++ code with variable assignments. I don't want to ship the text file along with my application; I'd prefer to compile it into it. So I tried the following:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  int main() {
      std::string test = R"(
  #include &lt;textresource.txt&gt;
  )";
      std::cerr &lt;&lt; test &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>I expected the <code>#include</code> in line 6 to be executed at preprocessing time, getting replaced with the contents of the resource file. After that, the compiler would see a raw string literal with the resource data.</p>
  
  <p>However, the output is simply the text <code>#include &lt;textresource.txt&gt;</code> with newlines around it. So apparently, the <code>#include</code> is never executed. (I'm using Visual Studio 2015.)</p>
  
  <p>Why doesn't the <code>#include</code> work as expected? Is there some other syntax that will import a text file (not code) into a variable at compile time?</p>