[Serialization: Newbie] Compilation Problem Text Archive
Hi,
I'm facing some compilation problem when I use text archive. But the same
code works fine when I use binary archive. And it does write something on
disk with specified file name (I'm yet to finish the restore part.
Otherwise, I could've said it works). Do I need to do something differently?
The error I get is something like following:
------------------------------------------------------------------------------------------
/boost/1_35_0/include/boost/archive/detail/oserializer.hpp: In function
‘void boost::archive::save(Archive&, T&) [with Archive =
boost::archive::text_oarchive, T = TableMgr*]’:
/boost/1_35_0/include/boost/archive/detail/common_oarchive.hpp:64:
instantiated from ‘void
boost::archive::detail::common_oarchive<Archive>::save_override(T&, int)
[with T = TableMgr*, Archive = boost::archive::text_oarchive]’
/boost/1_35_0/include/boost/archive/basic_text_oarchive.hpp:75:
instantiated from ‘void
boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with T
= TableMgr*, Archive = boost::archive::text_oarchive]’
/boost/1_35_0/include/boost/archive/detail/interface_oarchive.hpp:64:
instantiated from ‘Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T
= TableMgr*, Archive = boost::archive::text_oarchive]’
/remote/gsoumen/hiers/trunk/code/cmds/Cmds.cpp:1518: instantiated from
here
/boost/1_35_0/include/boost/archive/detail/oserializer.hpp:564: error:
invalid application of ‘sizeof’ to incomplete type
‘boost::STATIC_ASSERTION_FAILURE<false>’
cc1plus: warnings being treated as errors
------------------------------------------------------------------------------------------
My code is something like following:
#include
Are there any comments at oserializer.hpp line # 564 ? Robert Ramey Soumen wrote:
Hi,
I'm facing some compilation problem when I use text archive. But the same code works fine when I use binary archive. And it does write something on disk with specified file name (I'm yet to finish the restore part. Otherwise, I could've said it works). Do I need to do something differently?
The error I get is something like following: ------------------------------------------------------------------------------------------ /boost/1_35_0/include/boost/archive/detail/oserializer.hpp: In function 'void boost::archive::save(Archive&, T&) [with Archive = boost::archive::text_oarchive, T = TableMgr*]': /boost/1_35_0/include/boost/archive/detail/common_oarchive.hpp:64: instantiated from 'void boost::archive::detail::common_oarchive<Archive>::save_override(T&, int) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /boost/1_35_0/include/boost/archive/basic_text_oarchive.hpp:75: instantiated from 'void boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /boost/1_35_0/include/boost/archive/detail/interface_oarchive.hpp:64: instantiated from 'Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /remote/gsoumen/hiers/trunk/code/cmds/Cmds.cpp:1518: instantiated from here /boost/1_35_0/include/boost/archive/detail/oserializer.hpp:564: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' cc1plus: warnings being treated as errors ------------------------------------------------------------------------------------------
My code is something like following:
#include
#include //I use binary archive hpp when I use binary archive mode #include
#include std::ofstream ofs(fileName.c_str(), ios_base::out); // with bin archive I also use ios_base::binary boost::archive::text_oarchive oarchive(ofs); //for bin archive, oarchive is of binary_oarchive type
TableMgr *tblMgr = TableMgr::instance(); if (tblMgr) { oarchive << tblMgr; }
//I've TableMgr::serialize() defined ...
Regards, ~ Soumen
Hi, This is what is there: // if your program traps here, it indicates that your doing one of the following: // a) serializing an object of a type marked "track_never" through a pointer. // b) saving an non-const object of a type not markd "track_never) // Either of these conditions may be an indicator of an error usage of the // serialization library and should be double checked. See documentation on // object tracking. Also, see the "rationale" section of the documenation // for motivation for this checking. I'm _not_ explicitly using track_never through BOOST_CLASS_TRACKING macro. If I'm using something incorrectly, how does it (same code) work with binary_oarchive? Regards, ~ Soumen Robert Ramey wrote:
Are there any comments at oserializer.hpp line # 564 ?
Robert Ramey
Soumen wrote:
Hi,
I'm facing some compilation problem when I use text archive. But the same code works fine when I use binary archive. And it does write something on disk with specified file name (I'm yet to finish the restore part. Otherwise, I could've said it works). Do I need to do something differently?
The error I get is something like following: ------------------------------------------------------------------------------------------ /boost/1_35_0/include/boost/archive/detail/oserializer.hpp: In function 'void boost::archive::save(Archive&, T&) [with Archive = boost::archive::text_oarchive, T = TableMgr*]': /boost/1_35_0/include/boost/archive/detail/common_oarchive.hpp:64: instantiated from 'void boost::archive::detail::common_oarchive<Archive>::save_override(T&, int) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /boost/1_35_0/include/boost/archive/basic_text_oarchive.hpp:75: instantiated from 'void boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /boost/1_35_0/include/boost/archive/detail/interface_oarchive.hpp:64: instantiated from 'Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /remote/gsoumen/hiers/trunk/code/cmds/Cmds.cpp:1518: instantiated from here /boost/1_35_0/include/boost/archive/detail/oserializer.hpp:564: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' cc1plus: warnings being treated as errors ------------------------------------------------------------------------------------------
My code is something like following:
#include
#include //I use binary archive hpp when I use binary archive mode #include
#include std::ofstream ofs(fileName.c_str(), ios_base::out); // with bin archive I also use ios_base::binary boost::archive::text_oarchive oarchive(ofs); //for bin archive, oarchive is of binary_oarchive type
TableMgr *tblMgr = TableMgr::instance(); if (tblMgr) { oarchive << tblMgr; }
//I've TableMgr::serialize() defined ...
Regards, ~ Soumen
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/-Serialization%3A-Newbie--Compilation-Problem-Text-Arc... Sent from the Boost - Users mailing list archive at Nabble.com.
Try const TableMgr *tblMgr = TableMgr::instance(); if (tblMgr) { oarchive << tblMgr; } Robert Ramey Soumen wrote:
Hi,
This is what is there:
// if your program traps here, it indicates that your doing one of the following: // a) serializing an object of a type marked "track_never" through a pointer. // b) saving an non-const object of a type not markd "track_never) // Either of these conditions may be an indicator of an error usage of the // serialization library and should be double checked. See documentation on // object tracking. Also, see the "rationale" section of the documenation // for motivation for this checking.
I'm _not_ explicitly using track_never through BOOST_CLASS_TRACKING macro.
If I'm using something incorrectly, how does it (same code) work with binary_oarchive?
Regards, ~ Soumen
Robert Ramey wrote:
Are there any comments at oserializer.hpp line # 564 ?
Robert Ramey
Soumen wrote:
Hi,
I'm facing some compilation problem when I use text archive. But the same code works fine when I use binary archive. And it does write something on disk with specified file name (I'm yet to finish the restore part. Otherwise, I could've said it works). Do I need to do something differently?
The error I get is something like following: ------------------------------------------------------------------------------------------ /boost/1_35_0/include/boost/archive/detail/oserializer.hpp: In function 'void boost::archive::save(Archive&, T&) [with Archive = boost::archive::text_oarchive, T = TableMgr*]': /boost/1_35_0/include/boost/archive/detail/common_oarchive.hpp:64: instantiated from 'void boost::archive::detail::common_oarchive<Archive>::save_override(T&, int) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /boost/1_35_0/include/boost/archive/basic_text_oarchive.hpp:75: instantiated from 'void boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /boost/1_35_0/include/boost/archive/detail/interface_oarchive.hpp:64: instantiated from 'Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = TableMgr*, Archive = boost::archive::text_oarchive]' /remote/gsoumen/hiers/trunk/code/cmds/Cmds.cpp:1518: instantiated from here /boost/1_35_0/include/boost/archive/detail/oserializer.hpp:564: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' cc1plus: warnings being treated as errors ------------------------------------------------------------------------------------------
My code is something like following:
#include
#include //I use binary archive hpp when I use binary archive mode #include
#include std::ofstream ofs(fileName.c_str(), ios_base::out); // with bin archive I also use ios_base::binary boost::archive::text_oarchive oarchive(ofs); //for bin archive, oarchive is of binary_oarchive type
TableMgr *tblMgr = TableMgr::instance(); if (tblMgr) { oarchive << tblMgr; }
//I've TableMgr::serialize() defined ...
Regards, ~ Soumen
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Robert, I've tried this - but I get errors later on with invalid const conversion in the serialize function of TableMgr for each members. Looks like I need to cascade const changes to all the classes. At this point that's overkill for me since my idea to try with text archive was to verify that save is happening correctly. So I've decided for now to proceed with restore routine with binary archive itself. Now, how do I need to call this with TableMgr as this is singleton with return value of pointer type (internal implementation is using non-pointer static object and instance() returns address of it)? None of following approaches compiles //Assume my input archive object is iarchive 1) TableMgr *tblMgr = TableMgr::instance(); iarchive >> tblMgr; 2) TableMgr *tblMgr = TableMgr::instance(); iarchive >> (TableMgr&)(*tblMgr); // with output archive similar approach works 3) iarchive >> TableMgr::instance() // similar usage works in some other code when instance() returns ref // I guess this is equivalent of (1) anyway If these approaches are correct, I think some problem must be there with serialize() methods. I can concentrate there in that case. If these approaches are incorrect, please guide me how should I use it. Thanks, ~ Soumen Try const TableMgr *tblMgr = TableMgr::instance(); if (tblMgr) { oarchive << tblMgr; } Robert Ramey -- View this message in context: http://www.nabble.com/-Serialization%3A-Newbie--Compilation-Problem-Text-Arc... Sent from the Boost - Users mailing list archive at Nabble.com.
BTW, I'm using boost 1.35 and GCC 4.2.2. Hi Robert, I've tried this - but I get errors later on with invalid const conversion in the serialize function of TableMgr for each members. Looks like I need to cascade const changes to all the classes. At this point that's overkill for me since my idea to try with text archive was to verify that save is happening correctly. So I've decided for now to proceed with restore routine with binary archive itself. Now, how do I need to call this with TableMgr as this is singleton with return value of pointer type (internal implementation is using non-pointer static object and instance() returns address of it)? None of following approaches compiles //Assume my input archive object is iarchive 1) TableMgr *tblMgr = TableMgr::instance(); iarchive >> tblMgr; 2) TableMgr *tblMgr = TableMgr::instance(); iarchive >> (TableMgr&)(*tblMgr); // with output archive similar approach works 3) iarchive >> TableMgr::instance() // similar usage works in some other code when instance() returns ref // I guess this is equivalent of (1) anyway If these approaches are correct, I think some problem must be there with serialize() methods. I can concentrate there in that case. If these approaches are incorrect, please guide me how should I use it. Thanks, ~ Soumen Robert Ramey wrote:
Try
const TableMgr *tblMgr = TableMgr::instance(); if (tblMgr) { oarchive << tblMgr; }
Robert Ramey
-- View this message in context: http://www.nabble.com/-Serialization%3A-Newbie--Compilation-Problem-Text-Arc... Sent from the Boost - Users mailing list archive at Nabble.com.
For 1 and 3, I get error like following: ------------------------------------------------------------------------------ /remote/gsoumen/hiers/trunk/code/cmds/Cmds.cpp:1588: error: no match for ‘operator>>’ in ‘inputArchive >> tblMgr’ /boost/1_35_0/include/boost/archive/detail/interface_iarchive.hpp:62: note: candidates are: Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = TableMgr*, Archive = boost::archive::binary_iarchive] ------------------------------------------------------------------------------ Regards, ~ Soumen -- View this message in context: http://www.nabble.com/-Serialization%3A-Newbie--Compilation-Problem-Text-Arc... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Robert Ramey
-
Soumen