title: Check if bool is defined in mixed C/C++
body: <p>So I'm having issues with some code that I've inherited.  This code was building fine in a C-only environment, but now I need to use C++ to call this code.  The header <code>problem.h</code> contains:</p>
  
  <pre><code>#ifndef _BOOL
  typedef unsigned char bool;
  static const bool False = 0;
  static const bool True = 1;
  #endif
  
  struct astruct
  {
    bool myvar;
    /* and a bunch more */
  }
  </code></pre>
  
  <p>When I compile it as C++ code, I get <code>error C2632: 'char' followed by 'bool' is illegal</code></p>
  
  <p>I get the same error if I wrap the <code>#include "problem.h"</code> in <code>extern "C" { ... }</code> (which I don't understand, because there should be no keyword <code>bool</code> when compiling as C?)</p>
  
  <p>I tried removing the block from <code>#ifndef _BOOL</code> to <code>#endif</code>, and compiling as C++, and I get errors:</p>
  
  <p><code>error C2061: C requires that a struct or union has at least one member</code><br>
  <code>error C2061: syntax error: identifier 'bool'</code></p>
  
  <p>I just don't understand how the C++ compiler is complaining about a redefinition of <code>bool</code>, yet when I remove the redefinition and try to just use <code>bool</code> to define variables, it doesn't find anything.</p>
  
  <p>Any help is greatly appreciated.</p>