On 24/03/2017 09:26, Christopher Pisz wrote:
The following comparison fails for an error whom outputs "asio.misc" for errorCode.category().name() and "end of file" for errorCode.message()
If it claims to be in category asio.misc, then why does the if condition of (errorCode.category() == boost::asio::error::misc_category ) evaluate to false?
Googling says that a boost::system::error_code can have the same value in more than one category, so I assume that in order to get the proper message and meaning we must compare boost::system::error_category as well as boost::system::error_code::value.
How do we properly compare the category if this fails to work?
If they appear to have equal value but aren't equal, you might have a problem with multiple definitions. The most common problem is where you're using some shared libraries (DLL or SO) and trying to pass errors across the boundary. This works as expected only when you ensure that the dependencies of both sides also use the Boost libraries (esp. ASIO and System) as shared libraries, not as static libraries. When you're linking your Boost-using application with Boost-using shared libraries (and when the Boost types are used in the API between them), it's generally best to ensure that the shared libraries are used. On Linux, this generally just happens (as long as the shared libraries have been compiled and are in the same or earlier library path as the static libraries), but on Windows you should also define BOOST_ALL_DYN_LINK on both sides.