title: C++ Visual studio compiler warning C4800: 'int' : forcing value to bool 'true' or 'false'
body: <p>The following piece of code throwing <strong>warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)</strong>. Moving #define true and false after string and map header inclusions not throwing this warning. This is a sample code and in the actual code #define true and false are defined in one of our product library header files. So I want to understand why this warning is thrown by visual studio and why it is going away when #define moved after string and map header inclusions.</p>
  
  <pre><code>#ifndef true
  #define true    1
  #endif
  
  #ifndef false
  #define false   0
  #endif
  
  #include &lt;string&gt;
  #include &lt;map&gt;
  
  int main()
  {
      std::map&lt;std::string, std::string&gt; pair;
      pair.insert(std::make_pair("Key1", "Value1"));
      return 0;
  }
  </code></pre>
  
  <p>Full details of warning:</p>
  
  <pre><code>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\utility(144): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
  1&gt;          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(1801) : see reference to function template instantiation 'std::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,bool&gt;::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,int,void&gt;(_Other1 &amp;&amp;,_Other2 &amp;&amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=std::string
  1&gt;  ,            _Ty=std::string
  1&gt;  ,            _Other1=std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const std::string,std::string&gt;&gt;&gt;&gt;
  1&gt;  ,            _Other2=int
  1&gt;          ]
  1&gt;          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(1801) : see reference to function template instantiation 'std::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,bool&gt;::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,int,void&gt;(_Other1 &amp;&amp;,_Other2 &amp;&amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=std::string
  1&gt;  ,            _Ty=std::string
  1&gt;  ,            _Other1=std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const std::string,std::string&gt;&gt;&gt;&gt;
  1&gt;  ,            _Other2=int
  1&gt;          ]
  1&gt;          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(1160) : see reference to function template instantiation 'std::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,bool&gt; std::_Tree&lt;std::_Tmap_traits&lt;_Kty,_Ty,_Pr,_Alloc,false&gt;&gt;::_Insert_nohint&lt;std::pair&lt;const _Kty,_Ty&gt;&amp;,std::_Tree_node&lt;std::pair&lt;const _Kty,_Ty&gt;,void *&gt;*&gt;(bool,_Valty,_Nodety)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=std::string
  1&gt;  ,            _Ty=std::string
  1&gt;  ,            _Pr=std::less&lt;std::string&gt;
  1&gt;  ,            _Alloc=std::allocator&lt;std::pair&lt;const std::string,std::string&gt;&gt;
  1&gt;  ,            _Valty=std::pair&lt;const std::string,std::string&gt; &amp;
  1&gt;  ,            _Nodety=std::_Tree_node&lt;std::pair&lt;const std::string,std::string&gt;,void *&gt; *
  1&gt;          ]
  1&gt;          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(1160) : see reference to function template instantiation 'std::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,bool&gt; std::_Tree&lt;std::_Tmap_traits&lt;_Kty,_Ty,_Pr,_Alloc,false&gt;&gt;::_Insert_nohint&lt;std::pair&lt;const _Kty,_Ty&gt;&amp;,std::_Tree_node&lt;std::pair&lt;const _Kty,_Ty&gt;,void *&gt;*&gt;(bool,_Valty,_Nodety)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=std::string
  1&gt;  ,            _Ty=std::string
  1&gt;  ,            _Pr=std::less&lt;std::string&gt;
  1&gt;  ,            _Alloc=std::allocator&lt;std::pair&lt;const std::string,std::string&gt;&gt;
  1&gt;  ,            _Valty=std::pair&lt;const std::string,std::string&gt; &amp;
  1&gt;  ,            _Nodety=std::_Tree_node&lt;std::pair&lt;const std::string,std::string&gt;,void *&gt; *
  1&gt;          ]
  1&gt;          Source.cpp(41) : see reference to function template instantiation 'std::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,bool&gt; std::_Tree&lt;std::_Tmap_traits&lt;_Kty,_Ty,_Pr,_Alloc,false&gt;&gt;::insert&lt;std::pair&lt;const char *,const char *&gt;&gt;(_Valty &amp;&amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=std::string
  1&gt;  ,            _Ty=std::string
  1&gt;  ,            _Pr=std::less&lt;std::string&gt;
  1&gt;  ,            _Alloc=std::allocator&lt;std::pair&lt;const std::string,std::string&gt;&gt;
  1&gt;  ,            _Valty=std::pair&lt;const char *,const char *&gt;
  1&gt;          ]
  1&gt;          Source.cpp(41) : see reference to function template instantiation 'std::pair&lt;std::_Tree_iterator&lt;std::_Tree_val&lt;std::_Tree_simple_types&lt;std::pair&lt;const _Kty,_Ty&gt;&gt;&gt;&gt;,bool&gt; std::_Tree&lt;std::_Tmap_traits&lt;_Kty,_Ty,_Pr,_Alloc,false&gt;&gt;::insert&lt;std::pair&lt;const char *,const char *&gt;&gt;(_Valty &amp;&amp;)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              _Kty=std::string
  1&gt;  ,            _Ty=std::string
  1&gt;  ,            _Pr=std::less&lt;std::string&gt;
  1&gt;  ,            _Alloc=std::allocator&lt;std::pair&lt;const std::string,std::string&gt;&gt;
  1&gt;  ,            _Valty=std::pair&lt;const char *,const char *&gt;
  1&gt;          ]
  </code></pre>