Opened 12 years ago
#4816 new Bugs
[BOOST::ASIO] Under Cygwin <boost/asio.hpp> doesn't compile
| Reported by: | Owned by: | chris_kohlhoff | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | asio |
| Version: | Boost 1.43.0 | Severity: | Problem |
| Keywords: | boost::asio pipe_select_interrupter | Cc: |
Description
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
Attachments (3)
Change History (3)
by , 12 years ago
| Attachment: | boost_asio_bug_cygwin.cpp added |
|---|
by , 12 years ago
| Attachment: | boost_asio_bug_cygwin_with_fix.cpp added |
|---|
A corrected version which compiles correctly

Program demonstrating the bug