Re: [Boost-users] [Serialization] 1.33 RC1 nvp.hpp gotcha
I am a bit baffled why you can get the example to compile! I can't try it on VC7.1 today, though I will tomorrow, however I can't see anything compiler specific about it: Serialization/nvp.hpp includes serialization/traits.hpp that defines BOOST_SERIALIZATION_TRAITS_HPP. Serialization/vector.hpp includes collections_save_imp.hpp that includes archive/basic_archive.hpp that checks for BOOST_SERIALIZATION_TRAITS_HPP being defined and thereby says #error. Therefore it appears that whenever vector.hpp is included after nvp.hpp that basic_archive will choke. BTW When I said that perhaps it only worked by luck before I meant that my application worked by luck as I was not overly careful about header inclusion order or what went in the precompiled headers and what didn't. I did _not_ mean that it's lucky the serialization library works! I have found it very simple to use and very powerful. Richard -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: 09 August 2005 17:11 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] 1.33 RC1 nvp.hpp gotcha Richard Jennings wrote:
I have found that the requirement that no serialization headers can be
included before any archive headers means that you have to be careful which serialization headers you include in your class headers and indeed in what order you include them.
It is my intention that this issue be addressed with the simple rule: "all headers from the serialization directory should follow and headers from the archive directory" I believe that this rule should be very easy to follow. As a beneficial side-effect of flagging any usage of "archive" headers in include modules for classes. This would accidently link a serialization definition with implementation of a specific archive.
In particular if you include serialization/nvp.hpp before serialization/vector.hpp and you use that class in another module that does not use archiving at all then that module will hit the error directive, example below.
This would surprise me. Your example looks good to me. So I built on my own machine. Both main.cpp and B.cpp compiled without problems with VC 7.1 . So we're out of sync somehow.
A solution would seem to be that serialization/nvp.hpp should only be included in the module that includes archive headers.
This wouldn't work and shouldn't be necessary. Lets beat upon your example some more until we get the same results.
I guess what I would like is some guidance on using serialization as it's become a bit more tricky in my experience.
I would hope that its not too tricky. The system is designed to be as tricky as necessary - but no trickier.
At least you can't willy-nilly include serialization headers in any order in any headers and expect the application to compile.
True
Perhaps it only worked by luck before!
LOL - well I do consider myself a lucky person !!! But
A very small observation on your code:
#include <vector> // note this is superflous - but harmless
#include
On 8/10/05, Richard Jennings
I am a bit baffled why you can get the example to compile! I can't try it on VC7.1 today, though I will tomorrow, however I can't see anything compiler specific about it:
Compiling your examples gives me these errors(VC7.1): d:\boost\boost\serialization\tracking.hpp(50) : error C2065: 'is_pointer' : undeclared identifier d:\boost\boost\serialization\tracking.hpp(66) : see reference to class template instantiation 'boost::serialization::tracking_level<T>' being compiled d:\boost\boost\serialization\tracking.hpp(50) : error C2974: 'boost::mpl::eval_if' : invalid template argument for 'C', type expected d:\boost\boost\mpl\eval_if.hpp(44) : see declaration of 'boost::mpl::eval_if' d:\boost\boost\serialization\tracking.hpp(64) : error C2977: 'boost::mpl::eval_if' : too many template arguments d:\boost\boost\mpl\eval_if.hpp(44) : see declaration of 'boost::mpl::eval_if' d:\boost\boost\serialization\tracking.hpp(64) : error C2059: syntax error : '>' d:\boost\boost\serialization\tracking.hpp(64) : error C2039: 'type' : is not a member of 'operator``global namespace''' d:\boost\boost\serialization\tracking.hpp(64) : error C2238: unexpected token(s) preceding ';' d:\boost\boost\archive\basic_archive.hpp(21) : fatal error C1189: #error : "no serialization headers my precede any archive headers" shouldnt be "no seriazlization headers *may* precede any archive headers"? 'may' instead of 'my'. regards, Felipe. -- Felipe Magno de Almeida Developer from synergy and Computer Science student from State University of Campinas(UNICAMP). Unicamp: http://www.ic.unicamp.br Synergy: http://www.synergy.com.br "There is no dark side of the moon really. Matter of fact it's all dark."
Are you using the CVS development or the Release branch. I made a change to address this on the release branch. Its my understanding that changes on the release branch will be merged back into the main development trunk so this should be sufficient. Robert Ramey Felipe Magno de Almeida wrote:
On 8/10/05, Richard Jennings
wrote: I am a bit baffled why you can get the example to compile! I can't try it on VC7.1 today, though I will tomorrow, however I can't see anything compiler specific about it:
Compiling your examples gives me these errors(VC7.1):
d:\boost\boost\serialization\tracking.hpp(50) : error C2065: 'is_pointer' : undeclared identifier d:\boost\boost\serialization\tracking.hpp(66) : see reference to class template instantiation 'boost::serialization::tracking_level<T>' being compiled d:\boost\boost\serialization\tracking.hpp(50) : error C2974: 'boost::mpl::eval_if' : invalid template argument for 'C', type expected d:\boost\boost\mpl\eval_if.hpp(44) : see declaration of 'boost::mpl::eval_if' d:\boost\boost\serialization\tracking.hpp(64) : error C2977: 'boost::mpl::eval_if' : too many template arguments d:\boost\boost\mpl\eval_if.hpp(44) : see declaration of 'boost::mpl::eval_if' d:\boost\boost\serialization\tracking.hpp(64) : error C2059: syntax error : '>' d:\boost\boost\serialization\tracking.hpp(64) : error C2039: 'type' : is not a member of 'operator``global namespace''' d:\boost\boost\serialization\tracking.hpp(64) : error C2238: unexpected token(s) preceding ';' d:\boost\boost\archive\basic_archive.hpp(21) : fatal error C1189: #error : "no serialization headers my precede any archive headers"
shouldnt be "no seriazlization headers *may* precede any archive headers"? 'may' instead of 'my'.
regards, Felipe.
participants (3)
-
Felipe Magno de Almeida
-
Richard Jennings
-
Robert Ramey