|
Boost Users : |
From: Richard Jennings (Richard.Jennings_at_[hidden])
Date: 2005-08-10 04:00:20
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_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert Ramey
Sent: 09 August 2005 17:11
To: boost-users_at_[hidden]
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 <boost/serialization/vector.hpp> // as the above is included by
this module
Robert Ramey
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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