3

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??
Lexi
  • 1,670
  • 1
  • 19
  • 35
  • My first guess is broken. Do you get the same giberrish with `std::cout << boost::system::system_category().message( 9 )` or `std::cout << boost::system::system_category().message( boost::system::errc::bad_file_descriptor )` – Dave S Aug 30 '12 at 18:57
  • @DaveS Yeah, both: [image](http://i.imgur.com/sdJaQ.png) – Lexi Aug 30 '12 at 19:04
  • 1
    You have compiled boost.system using `libc++` too, right? LLVM's `libc++` and GNU's `libstdc++` aren't ABI compatible... – fgp Oct 04 '12 at 20:10
  • 1
    @fgp That was it, thanks. If you would like to make an answer, I'll set it as correct. ([How to compile/link Boost with clang++/libc++?](http://stackoverflow.com/q/8486077/823542) was rather helpful, if anyone else runs into this issue) – Lexi Oct 14 '12 at 06:35

1 Answers1

1

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.

fgp
  • 8,126
  • 1
  • 17
  • 18