[Boost-bugs] [Boost C++ Libraries] #4816: [BOOST::ASIO] Under Cygwin <boost/asio.hpp> doesn't compile

Subject: [Boost-bugs] [Boost C++ Libraries] #4816: [BOOST::ASIO] Under Cygwin <boost/asio.hpp> doesn't compile
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-05 16:22:42


#4816: [BOOST::ASIO] Under Cygwin <boost/asio.hpp> doesn't compile
-------------------------------------------------+--------------------------
 Reporter: frederic.jardon@… | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.43.0 | Severity: Problem
 Keywords: boost::asio pipe_select_interrupter |
-------------------------------------------------+--------------------------
 Environment: Cygwin

 Compiler: gcc

 == 1st issue
 boost/asio.hpp includes another header making references to the
 'pipe_select_interrupter' but fails to include:
 boost/asio/detail/pipe_select_interrupter.hpp
 Where it is effectively defined

 == 2nd issue
 The C function 'cfgetospeed' is referenced by:
 boost/asio/impl/serial_port_base.ipp

 But the inclusion of <termios.h> is not done under Cygwin and more,
 the cfgetospeed function is a macro, hence the statement on line 135
 fails:

 {{{
  speed_t baud = ::cfgetospeed(&storage);
 }}}

 == 3rd issue
 boost/asio/detail/buffer_sequence_adapter.hpp

 Makes references to the WSABUF structure when under Cygwin, but this
 structure exists only under the WIN32 environment. To compile I have to
 undefine the {{{__CYGWIN__}}} macro before including this header.

 == How to reproduce
 The following program doesn't compile:
 {{{
 /// gcc -c bug.cpp doesn't compile
 #include <cstdlib>
 #include <cstring>
 #include <iostream>

 #include <boost/asio.hpp>

 int main(int argc, char* argv[])
 {
         return 0;
 }
 }}}

 === User fix
 I fix these issue in my programs by adding the following code BEFORE
 including <boost/asio.hpp>

 {{{
 /// 1st issue
 #include <boost/asio/detail/pipe_select_interrupter.hpp>

 /// 2nd issue
 #ifdef __CYGWIN__
 #include <termios.h>
 #ifdef cfgetospeed
 #define __cfgetospeed__impl(tp) cfgetospeed(tp)
 #undef cfgetospeed
 inline speed_t cfgetospeed(const struct termios *tp)
 {
         return __cfgetospeed__impl(tp);
 }
 #undef __cfgetospeed__impl
 #endif /// cfgetospeed is a macro

 /// 3rd issue
 #undef __CYGWIN__
 #include <boost/asio/detail/buffer_sequence_adapter.hpp>
 #define __CYGWIN__
 #endif
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4816>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC