title: Can I redefine a C++ macro then define it back?
body: <p>I am using both the JUCE Library and a number of Boost headers in my code.  Juce defines "T" as a macro (groan), and Boost often uses "T" in it's template definitions.  The result is that if you somehow include the JUCE headers before the Boost headers the preprocessor expands the JUCE macro in the Boost code, and then the compiler gets hopelessly lost.</p>
  
  <p>Keeping my includes in the right order isn't hard most of the time, but it can get tricky when you have a JUCE class that includes some other classes and somewhere up the chain one file includes Boost, and if any of the files before it needed a JUCE include you're in trouble.</p>
  
  <p>My initial hope at fixing this was to</p>
  
  <pre><code>#undef T
  </code></pre>
  
  <p>before any includes for Boost.  But the problem is, if I don't re-define it, then other code gets confused that "T" is not declared.</p>
  
  <p>I then thought that maybe I could do some circular #define trickery like so:</p>
  
  <pre><code>// some includes up here
  #define ___T___ T
  #undef T
  // include boost headers here
  #define T ___T___
  #undef ___T___
  </code></pre>
  
  <p>Ugly, but I thought it may work.</p>
  
  <p>Sadly no. I get errors in places using "T" as a macro that </p>
  
  <pre><code>'___T___' was not declared in this scope.
  </code></pre>
  
  <p>Is there a way to make these two libraries work reliably together?</p>