title: Preserving preprocessor definitions
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1793800/can-i-redefine-a-c-macro-then-define-it-back">Can I redefine a C++ macro then define it back?</a>  </p>
  </blockquote>
  
  
  
  <p>Say I have some code that uses the name <code>BLAH</code> for a variable. Suppose <code>BLAH</code> is a common preprocessor definition in many standard header files (defined as 10), so if my file is included after any of them, the code breaks because <code>BLAH</code> is transformed into 10; therefore, I must <code>#undef BLAH</code>. But also other headers may depend on <code>BLAH</code>, so I must restore <code>BLAH</code> to it's original value after my header is done. Is it possible to do something like this:</p>
  
  <pre><code>#ifdef BLAH
  #define BLAH_OLD BLAH
  #undef BLAH
  #endif
  
  ... code ...
  
  // restore BLAH to 10
  #ifdef BLAH_OLD
  #define BLAH BLAH_OLD
  #end
  </code></pre>
  
  <p>? This doesn't work of course, because BLAH is not expanded to 10. I have tried doing something like</p>
  
  <pre><code>#define EXPAND_AGAIN(x) x
  #define EXPAND(x) EXPAND_AGAIN(x)
  #define BLAH_OLD EXPAND(BLAH)
  </code></pre>
  
  <p>but that doesn't work either, since EXPAND is taken literally and not expanded. I am using MSVC 2008/2010, but it would be lovely if the solution would work on most other compilers too.</p>