motam79
motam79

Reputation: 3824

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.

Upvotes: 1

Views: 1006

Answers (2)

motam79
motam79

Reputation: 3824

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.

Upvotes: 2

sehe
sehe

Reputation: 392911

Yes this looks like a version conflict.

Note that since it is a compile error on the implementation details of access_control, it could very well be due to different compiler flags/config resulting in different code being compiled in. This would be a problem even if all includes are from the same Boost release.

In particular, some part of the code may be making (different) assumptions about the target platform.

Upvotes: 2

Related Questions