Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost::system::error_code::message comes out as gibberish with -stdlib=libc++

I'm using Boost 1.51 under OS X 10.7.4 and I've found that linking against the C++11 standard library causes boost's system error code message to output complete gibberish.
Does anyone know why this might be, and how to stop it happening?

Example:

#include <iostream>
#include <boost/system/error_code.hpp>

int main() {
    std::cout << "system_category(9): " << boost::system::system_category().message( 9 ) << std::endl;
    std::cout << "system_category(bad_file_desc): " << boost::system::system_category().message( boost::system::errc::bad_file_descriptor ) << std::endl;
    return 0;
}

$ c++ --version
Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix

$ c++ -lboost_system -o boost_error_codes boost_error_codes.cpp -std=c++11 && ./boost_error_codes
system_category(9): Bad file descriptor
system_category(bad_file_desc): Bad file descriptor

$ c++ -lboost_system -o boost_error_codes boost_error_codes.cpp -std=c++11 -stdlib=libc++ && ./boost_error_codes
system_category(9):     ?HJ?a?Q???t??
system_category(bad_file_desc):     ??U?a?? W?a?0W?a?X  ?HJ?a?Q???t??
like image 323
Lex R Avatar asked Aug 22 '26 04:08

Lex R


1 Answers

Have you compiled boost.system using libc++ too?

LLVM's libc++ and GNU's libstdc++ aren't ABI compatible, so if you haven't that's probably the culprit.

like image 171
fgp Avatar answered Aug 23 '26 19:08

fgp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!