|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2006-08-24 15:57:57
Dan Bikel wrote:
> The following tiny program generates two compiler errors on FC 5
> (which comes with g++ 4.1.1 and boost 1.33.1):
>
> #include <iostream>
> #include <fstream>
> #include <string>
> #include <boost/archive/text_oarchive.hpp>
> #include <boost/archive/text_iarchive.hpp>
> #include <boost/serialization/string.hpp>
>
> using namespace std;
> using namespace boost;
>
> int
> main(int argc, char **argv) {
> string * pFoo = new string("foo");
> ofstream ofs("strfile");
> {
> archive::text_oarchive oa(ofs);
> oa << pFoo;
> }
> }
>
> Error No. 1:
> /usr/include/boost/archive/detail/oserializer.hpp:567: error: invalid
> application of -1òøsizeofòù to incomplete type
> òøboost::STATIC_ASSERTION_FAILURE<false>
>
> Error No. 2:
> /usr/include/boost/serialization/access.hpp:109: error: -1òøstruct
> std::basic_string<char, std::char_traits<char>, std::allocator<char>
>> òù has no member named òøserializeòù
>
> Error No. 1 can be fixed by making pFoo a const pointer type, i.e., by
> changing the declaration/assignment statement to be
> string *const pFoo = new string("foo");
>
> I cannot figure out why such a change is necessary, as the
> serialization library documentation does not indicate that it is
> necessary to make pointers const in order to serialize them (as is
> borne out by the demo.cpp code). Also, I cannot figure out how to fix
> Error No. 2.
>
> Any help would be much appreciated!
>
> Thanks,
> Dan.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net