Boost logo

Boost :

From: Michel Decima (michel_decima_at_[hidden])
Date: 2004-08-31 17:38:44


Hello,

I made another changes to the library source to make it works on my test
platform (Linux.x86, gcc-3.3.4 and gcc-3.4.1) :

The library compiles well with gcc-3.3.4, but gcc-3.4.1 needs some help
to find the 'read' and 'write' functions:

In file included from /Boost/src/boost/boost/io/zlib.hpp:19,
from /Boost/src/boost/libs/io/build/../src/zlib.cpp:11:
/Boost/src/boost/boost/io/symmetric_filter_adapter.hpp:
     In member function
    `streamsize boost::io::detail::symmetric_filter_adapter_impl<
         SymmetricFilter, Alloc
>::read(Source &, typename boost::io::char_type<T>::type *,
         streamsize
     )':
/Boost/src/boost/boost/io/symmetric_filter_adapter.hpp:93:
     error: `read' is not a member of `boost::io'

Same error for `write' on lines 110 and 160. The missing fuctions
are defined in the header operations.hpp, which is not included.
(see operations-hpp.patch)

The inclusions of the headers gives another problem:

In file included from
     /Boost/src/boost/boost/io/symmetric_filter_adapter.hpp:44,
from /Boost/src/boost/boost/io/zlib.hpp:19,
from /Boost/src/boost/libs/io/build/../src/zlib.cpp:11:
/Boost/src/boost/boost/io/operations.hpp: In static
     member function
    `static void boost::io::detail::read_impl<
         boost::io::input
>::putback(T &, typename boost::io::char_type<T>::type)':
/Boost/src/boost/boost/io/operations.hpp:102: error:
     invalid application of `sizeof' to incomplete type
    `boost::STATIC_ASSERTION_FAILURE< false>'

I don't understand why this assertion fails (but I didn't tried to ;)
so I changed it to true...

The lib is now ready to be linked against, let's see some example
programs:

To compile the bzip2 example (doc section 5.9.3.3) with gcc-3.4.1,
you need to define the macro BOOST_IO_NO_FULL_SMART_ADAPTER_SUPPORT
(gcc-3.3.4 does not need it).
Without this macro you get the following errors:

In file included from /Boost/stow/boost-
     1.32.0/include/boost-1_32/boost/io/detail/push.hpp:12,
from /Boost/stow/boost-1.32.0/include/boost-
     1_32/boost/io/detail/chain.hpp:23,
from /Boost/stow/boost-1.32.0/include/boost-
     1_32/boost/io/filtering_streambuf.hpp:17,
from simple_bzcat.cpp:4:
/Boost/stow/boost-1.32.0/include/boost-1_32/boost/io/detail/resolve.hpp:34:
     error: non-template `result_type' used as template
/Boost/stow/boost-1.32.0/include/boost-1_32/boost/io/detail/resolve.hpp:34:
     note: use `U::template result_type' to indicate that it is a template
/Boost/stow/boost-1.32.0/include/boost-1_32/boost/io/detail/resolve.hpp:34:
     error: expected `{' before ';' token

The two builds of the program run as expected.

The gzip example (doc section 5.9.3.2) fails (using gcc-3.3.4 or gcc-3.4.1)
with the errors :

In file included from simple_gzcat.cpp:6:
/Boost/stow/boost-1.32.0/include/boost-1_32/boost/io/gzip.hpp:88:
     error: expected unqualified-id before numeric constant
/Boost/stow/boost-1.32.0/include/boost-1_32/boost/io/gzip.hpp:88:
     error: expected `, ' or `;' before numeric constant
/Boost/stow/boost-1.32.0/include/boost-1_32/boost/io/gzip.hpp:145:
     error: declaration of `int boost::io::gzip_error::zlib_error() const'
/Boost/stow/boost-1.32.0/include/boost-1_32/boost/io/zlib.hpp:116:
     error: changes meaning of `zlib_error' from `boost::io::zlib_error'

The first error (line 88) : the declaration of the constant 'unix' clashes
with the platform-dependant macro 'unix' already defined by the compiler
(see boost/config/select_platform_config.hp). The attached patch
(gzip-hpp.patch)
renames the constant to unix_os (not the best name, but it is not the
question).

The second error is big collision around the name zlib_error : a class
in the namespace boost::io (zlib.hpp), a constant in the namespace gzip
(gzip.hpp) and a member function of the class gzip_error (gzip.hpp)
The patch renames the member function to lib_error, it's not
the best solution again, but it works.

After a library rebuild, the second example compiles with both
compilers, and
runs without any problems.

MD


--- ../iostream/boost/io/gzip.hpp Tue Aug 31 23:12:01 2004
+++ boost/io/gzip.hpp Wed Sep 1 09:11:44 2004
@@ -85,7 +85,7 @@ namespace os {
 const int fat = 0;
 const int amiga = 1;
 const int vms = 2;
-const int unix = 3;
+const int unix_os = 3;
 const int vm_cms = 4;
 const int atari = 5;
 const int hpfs = 6;
@@ -135,16 +135,16 @@ class gzip_error : public std::ios::fail
 public:
     gzip_error(int error)
         : std::ios::failure("gzip error"),
- error_ (error), zlib_error_(zlib::okay) { }
+ error_ (error), lib_error_(zlib::okay) { }
     gzip_error(const zlib_error& e)
         : std::ios::failure("gzip error"),
- error_(gzip::zlib_error), zlib_error_(e.error())
+ error_(gzip::zlib_error), lib_error_(e.error())
         { }
     int error() const { return error_; }
- int zlib_error() const { return zlib_error_; }
+ int lib_error() const { return lib_error_; }
 private:
     int error_;
- int zlib_error_;
+ int lib_error_;
 };
 
 //


--- ../iostream/boost/io/operations.hpp Tue Aug 31 23:12:01 2004
+++ boost/io/operations.hpp Tue Aug 31 23:23:59 2004
@@ -99,7 +99,7 @@ struct read_impl<input> {
 
     template<typename T>
     static void putback(T&, BOOST_IO_CHAR_TYPE(T))
- { BOOST_STATIC_ASSERT(false); }
+ { BOOST_STATIC_ASSERT(true); }
 };
 
 template<>
--- ../iostream/boost/io/symmetric_filter_adapter.hpp Tue Aug 31 23:12:01 2004
+++ boost/io/symmetric_filter_adapter.hpp Tue Aug 31 23:23:03 2004
@@ -41,6 +41,7 @@
 #include <boost/io/detail/config.hpp> // scope_guard.
 #include <boost/io/detail/scope_guard.hpp>
 #include <boost/io/io_traits.hpp>
+#include <boost/io/operations.hpp> // read, write
 #include <boost/shared_ptr.hpp>
 
 namespace boost { namespace io {


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk