[iostreams] Problem using with MinGW GCC 3.4.2

Hi, I get the following error when trying to compile a simple test (attached) using vector_sink from the tutorial with MinGW GCC 3.4.2: boost_iostreams.cpp: In function `int main()': boost_iostreams.cpp:41: error: invalid operands of types `boost::io::streambuf_facade< vector_sink, char_traits<char>, boost::io::output > ()(vector_sink)' and `int' to binary `operator<<' Please accept my apologies if I've overlooked something crucial in the docs. In case it matters, here is a list of changes I made to make the lib compile cleanly: 1. E:\libs\boost\libs\iostreams\build\../src/mapped_file.cpp:168: error: `::GetFileSizeEx' has not been declared According to MSDN, GetFileSizeEx() is only available under Windows 2000 and newer, so I had to remove this file from Jamfile sources. Maybe there should be a define for this, like for the compression code. 2. E:/libs/boost/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:150: error: `default_filter_buffer_size' undeclared (first use this function) E:/libs/boost/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:151: error: `default_buffer_size' undeclared (first use this function) E:/libs/boost/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:155: error: `default_pback_buffer_size' undeclared (first use this function) Fixed by including 'boost/iostreams/constants.hpp'. 3. E:/libs/boost/boost/iostreams/categories.hpp:102: warning: virtual base `boost::io::input_seekable' inaccessible in `boost::io::iostream_tag' due to ambiguity E:/libs/boost/boost/iostreams/categories.hpp:102: warning: virtual base `boost::io::device_tag' inaccessible in `boost::io::iostream_tag' due to ambiguity E:/libs/boost/boost/iostreams/categories.hpp:102: warning: virtual base `boost::io::output_seekable' inaccessible in `boost::io::iostream_tag' due to ambiguity Fixed by replacing struct seekable_device_tag : device_tag, seekable { }; with struct seekable_device_tag : virtual device_tag, seekable { }; and struct seekable : input_seekable, output_seekable, detail::one_head { }; with struct seekable : virtual input_seekable, virtual output_seekable, detail::one_head { }; 4. E:/libs/boost/boost/iostreams/detail/streambuf/linked_streambuf.hpp:54: error: variable or field `close' declared void E:/libs/boost/boost/iostreams/detail/streambuf/linked_streambuf.hpp:54: error: `close' declared as a `virtual' field E:/libs/boost/boost/iostreams/detail/streambuf/linked_streambuf.hpp:54: error: expected `;' before '( ' token Fixed by including 'ios'. 5. E:/libs/boost/boost/iostreams/detail/streambuf/indirect_streambuf.hpp:377:1: warning: multi-line comment Fixed by changing to C-style comment. Not sure whether this is a problem with the code or GCC not handling the '\' in the macro definition properly. I also removed duplicate include of 'boost/iostreams/constants.hpp' in 'boost/iostreams/stream_facade.hpp'. TIA, -- Daniel Schlyder http://bitblaze.com/

Daniel Schlyder wrote:
Hi,
Thanks for the report! Looking briefly at your changes, I see that I have fixed some -- but probably not all -- of the problems you point out in the version I am currently working on. I'll make sure I fix all these problems before I post the new version, which will likely be tomorrow or the next day. Best Regards, Jonathan

Daniel Schlyder wrote:
Hi,
Hi,
I get the following error when trying to compile a simple test (attached) using vector_sink from the tutorial with MinGW GCC 3.4.2:
I'm sorry it took me so long to look at your test program. There are three problems: The first is that streambufs do not support operator<<. You have to use streams for that. So the first rewrite of your example would look like: #include <boost/iostreams/concepts.hpp> #include <boost/iostreams/stream_facade.hpp> ... int main() { std::vector<char> vec; boost::io::stream_facade<vector_sink> out(vector_sink(vec)); out << 123 << "foo"; std::copy( vec.begin(), vec.end(), std::ostream_iterator<char>(std::cout, "\n")); } The second problem is that the second line is being interpretted as a function declaration. One way to fix this is: int main() { std::vector<char> vec; vector_sink vs(vec); boost::io::stream_facade<vector_sink> out(vs); out << 123 << "foo"; std::copy( vec.begin(), vec.end(), std::ostream_iterator<char>(std::cout, "\n")); } In the version I am about to release, you can also do this, which is more elegant: #include <boost/ref.hpp> int main() { std::vector<char> vec; boost::io::stream_facade<vector_sink> out(boost::ref(vec)); out << 123 << "foo"; std::copy( vec.begin(), vec.end(), std::ostream_iterator<char>(std::cout, "\n")); } The last problem is that you need to flush or close the stream before you can rely on the data having being written to the vector. I hope I've answered your question.
Daniel Schlyder http://bitblaze.com/
Best Regards, Jonathan

Jonathan Turkanis: [...]
I hope I've answered your question.
Yes. I've tried these changes with the new version of Iostreams and everything works great. Thank you very much! I've posted another newbie question over on the user list, if you have time... Best regards, -- Daniel Schlyder http://bitblaze.com/
participants (2)
-
Daniel Schlyder
-
Jonathan Turkanis