title: Boost ASIO example does not build
body: <p>I'm trying to do the fist asio <a href="http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/tutorial/tuttimer1.html" rel="nofollow noreferrer">tutorial</a>.  I am using Boost 1.60, CLion 1.2 and Cygwin.</p>
  
  <p><strong>With this C++ code:</strong></p>
  
  <pre><code>    //
      // timer.cpp
      // ~~~~~~~~~
      //
      // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
      //
      // Distributed under the Boost Software License, Version 1.0. (See accompanying
      // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
      //
  
      #include &lt;iostream&gt;
      #include &lt;boost/asio.hpp&gt;
      #include &lt;boost/date_time/posix_time/posix_time.hpp&gt;
  
      int main()
      {
          boost::asio::io_service io;
  
          boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
          t.wait();
  
          std::cout &lt;&lt; "Hello, world!" &lt;&lt; std::endl;
  
          return 0;
      }
  </code></pre>
  
  <p><strong>And this CMake file:</strong></p>
  
  <pre><code>    cmake_minimum_required(VERSION 3.3)
      project(Test1)
  
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
      #add_compile_options(-D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501 -lboost_system -lws2_32)
      add_compile_options(-D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501)
  
  
  
      set(Boost_INCLUDE_DIR "D:\\Downloads\\boost_1_60_0\\boost_1_60_0")
  
      find_package(Boost)
      if (Boost_FOUND)
          include_directories(${Boost_INCLUDE_DIR})
      endif ()
  
  
      set(SOURCE_FILES main.cpp)
      add_executable(Test1 ${SOURCE_FILES})
  </code></pre>
  
  <p><strong>I get the following error:</strong></p>
  
  <pre><code>error: '__MSABI_LONG' was not declared in this scope        BOOST_ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE)
  </code></pre>
  
  <p>This error repeats a number of times over different macros.</p>
  
  <p>So using this <a href="https://stackoverflow.com/questions/25115192/compiling-boost-example-projects-with-cygwin-gcc">answer</a>, the code is changed to:</p>
  
  <p><strong>C++</strong></p>
  
  <pre><code>    //
      // timer.cpp
      // ~~~~~~~~~
      //
      // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
      //
      // Distributed under the Boost Software License, Version 1.0. (See accompanying
      // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
      //
      #define __MSABI_LONG(x)
  
      #include &lt;iostream&gt;
      #include &lt;boost/asio.hpp&gt;
      #include &lt;boost/date_time/posix_time/posix_time.hpp&gt;
  
      int main()
      {
          boost::asio::io_service io;
  
          boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
          t.wait();
  
          std::cout &lt;&lt; "Hello, world!" &lt;&lt; std::endl;
  
          return 0;
      }
  </code></pre>
  
  <p><strong>CMake</strong></p>
  
  <pre><code>    cmake_minimum_required(VERSION 3.3)
      project(Test1)
  
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
      add_compile_options(-D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501 -lboost_system -lws2_32)
  
  
  
      set(Boost_INCLUDE_DIR "D:\\Downloads\\boost_1_60_0\\boost_1_60_0")
  
      find_package(Boost)
      if (Boost_FOUND)
          include_directories(${Boost_INCLUDE_DIR})
      endif ()
  
  
      set(SOURCE_FILES main.cpp)
      add_executable(Test1 ${SOURCE_FILES})
  </code></pre>
  
  <p><strong>I get the following error</strong></p>
  
  <pre><code>error: expected primary-expression before ',' token BOOST_ASIO_NATIVE_ERROR(EPIPE))
  </code></pre>
  
  <p>I get this one a number of times as well.</p>
  
  <p><strong><em>Edit 1</em></strong></p>
  
  <p><strong>If I change the code to be:</strong></p>
  
  <pre><code>    //
      // timer.cpp
      // ~~~~~~~~~
      //
      // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
      //
      // Distributed under the Boost Software License, Version 1.0. (See accompanying
      // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
      //
      #define __MSABI_LONG(x) x
  
      #include &lt;iostream&gt;
      #include &lt;boost/asio.hpp&gt;
      #include &lt;boost/date_time/posix_time/posix_time.hpp&gt;
  
      int main()
      {
          boost::asio::io_service io;
  
          boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
          t.wait();
  
          std::cout &lt;&lt; "Hello, world!" &lt;&lt; std::endl;
  
          return 0;
      }
  </code></pre>
  
  <p><strong>Sample of error output:</strong></p>
  
  <pre><code>    D:/Downloads/boost_1_60_0/boost_1_60_0/boost/asio/detail/impl/winsock_init.ipp:36:44: error: cannot convert 'long int*' to 'volatile int*' for argument '1' to 'int _InterlockedIncrement(volatile int*)'
         if (::InterlockedIncrement(&amp;d.init_count_) == 1)
                                                  ^
      D:/Downloads/boost_1_60_0/boost_1_60_0/boost/asio/detail/impl/winsock_init.ipp:40:45: error: cannot convert 'long int*' to 'volatile int*' for argument '1' to 'int _InterlockedExchange(volatile int*, int)'
           ::InterlockedExchange(&amp;d.result_, result);
                                                   ^
      D:/Downloads/boost_1_60_0/boost_1_60_0/boost/asio/detail/impl/winsock_init.ipp: In static member function 'static void boost::asio::detail::winsock_init_base::manual_startup(boost::asio::detail::winsock_init_base::data&amp;)':
  
         if (::InterlockedIncrement(&amp;d.init_count_) == 1)
                                                  ^
      D:/Downloads/boost_1_60_0/boost_1_60_0/boost/asio/detail/impl/winsock_init.ipp:48:40: error: cannot convert 'long int*' to 'volatile int*' for argument '1' to 'int _InterlockedExchange(volatile int*, int)'
           ::InterlockedExchange(&amp;d.result_, 0);
  </code></pre>
  
  <p><strong><em>EDIT 2</em></strong></p>
  
  <p><strong>Change the CMake code to specify the correct OS in the compiler option yields this:</strong></p>
  
  <pre><code>    cmake_minimum_required(VERSION 3.3)
      project(Test1)
  
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
      add_compile_options(-D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0A00 -lboost_system -lws2_32)
  
  
  
      set(Boost_INCLUDE_DIR "D:\\AdrianMattocks\\Downloads\\boost_1_60_0\\boost_1_60_0")
  
      find_package(Boost)
      if (Boost_FOUND)
          include_directories(${Boost_INCLUDE_DIR})
      endif ()
  
  
      set(SOURCE_FILES main.cpp)
      add_executable(Test1 ${SOURCE_FILES})
  </code></pre>
  
  <p><strong>I get this error (this is just a sample due to SO size limits but these errors are repeated many times):</strong></p>
  
  <pre><code>    D:/Malachi/Downloads/boost_1_60_0/boost_1_60_0/boost/asio/detail/impl/winsock_init.ipp: In static member function 'static void boost::asio::detail::winsock_init_base::startup(boost::asio::detail::winsock_init_base::data&amp;, unsigned char, unsigned char)':
      D:/Malachi/Downloads/boost_1_60_0/boost_1_60_0/boost/asio/detail/impl/winsock_init.ipp:36:44: error: [Kno matching function for call to '_InterlockedIncrement(long int*)'
         if (::InterlockedIncrement(&amp;d.init_count_) == 1)
      D:/Malachi/Downloads/boost_1_60_0/boost_1_60_0/boost/asio/detail/impl/winsock_init.ipp:36:44: error: invalid conversion from 'long int*' to 'volatile long unsigned int*' [-fpermissive]
         if (::InterlockedIncrement(&amp;d.init_count_) == 1)
  </code></pre>
  
  <p>How do I fix this?</p>