Search code examples
c++boostboost-iostreamscpprest-sdk

C++ Boost-iostream: mysterious error when including filtering_streambuf.hpp


I have been using the boost iostream library (version 1.65) mostly using following header: <boost/iostreams/filtering_streambuf.hpp> , with no problems.

After I added another library called cpprest to my project(https://github.com/Microsoft/cpprestsdk). I get this warning in my cmake:

usr/bin/ld: warning: libboost_system.so.1.58.0, needed by /usr/lib/libcpprest.so, may conflict with libboost_system.so.1.65.0

Also after including the boost headers, I get this mysterious compile error:

/usr/local/include/boost/iostreams/detail/access_control.hpp: In constructor ‘boost::iostreams::detail::prot_<U>::prot_(V)’:
/usr/local/include/boost/iostreams/detail/access_control.hpp:37:43: error: class ‘boost::iostreams::detail::prot_<U>’ does not have any field named ‘v’
         template<typename V> prot_(V v) : U(v) { }

Is this caused by the incompatibility of Boost 1.58 (which is used by cpprest) and 1.65? Or is it a bug in Boost iostream?

I actually down-graded my boost to 1.58 but I still see the same error.


Solution

  • I figured out it was a problem with the definitions. The Microsoft code defines a macro call U(x) and the Boost code uses U as template variable. After adding #define _TURN_OFF_PLATFORM_STRING before importing the Microsoft code header, the problem was resolved.