title: Compiler errors using boost::asio/windows7/visual studio 2010
body: <p>I'm struggling since several hours trying to compile a boost::asio program on my system (win7, vs2010, boost 1.49). Boost has been properly builed and linked to my vs project. I made a test run with boost::regex and everything worked ok.</p>
  
  <p>The compiler complain about 2 headers (in6addr.h, ws2ipdef.h), about 90% being C2146 (syntax) and C2079 (undefined class/struc/union name) errors. </p>
  
  <p>A large amount of these errors relate to windows type definition (USHORT,ULONG...) and winsock definition(SOCKET_ADDRESS, ADDRESS_FAMILY) being undefined. A sample can be found at the end of this post.</p>
  
  <p>My includes are the following:</p>
  
  <pre><code>#pragma once
  
  #include "targetver.h"
  #include &lt;boost/asio.hpp&gt;
  #include &lt;boost/shared_ptr.hpp&gt;
  #include &lt;boost/cstdint.hpp&gt;
  #include &lt;boost/bind.hpp&gt;
  #include &lt;boost/enable_shared_from_this.hpp&gt;
  #include &lt;stdio.h&gt;
  #include &lt;tchar.h&gt;
  #include &lt;string&gt;
  #include &lt;cassert&gt;
  #include &lt;vector&gt;
  #include &lt;cstdio&gt;
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;map&gt;
  #include &lt;sstream&gt;
  </code></pre>
  
  <ul>
  <li><p>I tried both file by file include definition and to gather up those
  in the precompiled header.</p></li>
  <li><p>Given that my problem seems related to winsock2 and windows
  definitions, i tried to include them in all possible ways using
  appropriate defineds (WIN32_LEAN_AND_MEAN..) an declaration order to
  no avail.</p></li>
  <li><p>I tried running winsock2 in a stand alone program and everything runned ok.</p></li>
  </ul>
  
  <p>My problem seem awfully similar to this one (tried out all advices / question unresolved):</p>
  
  <p><a href="http://www.developpez.net/forums/d585193/c-cpp/cpp/bibliotheques/boost/asio-erreur-syntaxe-specificateur-type-manquant-d/" rel="nofollow">http://www.developpez.net/forums/d585193/c-cpp/cpp/bibliotheques/boost/asio-erreur-syntaxe-specificateur-type-manquant-d/</a></p>
  
  <p>I've already broke 2 keyboards and seriously consider hanging myself with whats left of my mouse. Please help!</p>
  
  <p>Thanks in advance for your time.</p>
  
  <p>Thomas</p>
  
  <p>Error sample:</p>
  
  <p><strong>ws2ipdef.h</strong></p>
  
  <blockquote>
    <p>Erreur    171 error C2059: erreur de syntaxe : ')'    c:\program files
    (x86)\microsoft sdks\windows\v7.0a\include\ws2ipdef.h 336 1   asioProto
    Erreur    180 error C2059: erreur de syntaxe : ')'    c:\program files
    (x86)\microsoft sdks\windows\v7.0a\include\ws2ipdef.h 354 1   asioProto
    Erreur    189 error C2059: erreur de syntaxe : ')'    c:\program files
    (x86)\microsoft sdks\windows\v7.0a\include\ws2ipdef.h 372 1   asioProto
    Erreur    198 error C2059: erreur de syntaxe : ')'    c:\program files
    (x86)\microsoft sdks\windows\v7.0a\include\ws2ipdef.h 390 1   asioProto
    Erreur    18  error C2079: 'sockaddr_gen::Address' utilise une struct de
    'sockaddr' non défini c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\ws2ipdef.h 75  1   asioProto Erreur    19  error
    C2079: 'sockaddr_gen::AddressIn' utilise une struct de 'sockaddr_in'
    non défini    c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\ws2ipdef.h 76  1   asioProto Erreur    177 error
    C2086: 'int BOOLEAN' : redéfinition   c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\ws2ipdef.h 354 1   asioProto Erreur    186 error
    C2086: 'int BOOLEAN' : redéfinition   c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\ws2ipdef.h 372 1   asioProto</p>
  </blockquote>
  
  <p><strong>in6addr.h</strong></p>
  
  <blockquote>
    <p>Erreur    7   error C2143: erreur de syntaxe : absence de ';' avant
    '*'   c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\in6addr.h  27  1   asioProto Erreur    1   error
    C2146: erreur de syntaxe : absence de ';' avant l'identificateur
    'Byte'    c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\in6addr.h  24  1   asioProto Erreur    4   error
    C2146: erreur de syntaxe : absence de ';' avant l'identificateur
    'Word'    c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\in6addr.h  25  1   asioProto Erreur    2   error
    C4430: spécificateur de type manquant - int est pris en compte par
    défaut. Remarque : C++ ne prend pas en charge int par
    défaut    c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\in6addr.h  24  1   asioProto Erreur    3   error
    C4430: spécificateur de type manquant - int est pris en compte par
    défaut. Remarque : C++ ne prend pas en charge int par
    défaut    c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\in6addr.h  24  1   asioProto Erreur    5   error
    C4430: spécificateur de type manquant - int est pris en compte par
    défaut. Remarque : C++ ne prend pas en charge int par
    défaut    c:\program files (x86)\microsoft
    sdks\windows\v7.0a\include\in6addr.h  25  1   asioProto</p>
  </blockquote>