Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-09-17 14:16:24


Note that the only reason for using __declspec on tis platform is
that without it, programs compiled in release mode will optimize
away code not explicitly referred to. This breaks serialization
of derived pointers. So this is a hack to work around over-zealous
compiler optimizaton. This has been learned through painful and
time consuming experience. It is possible this solution is overkill
in some cases, but there is no way to know without investing
a lot more effort.

I have no idea if the serialization library will work with /clr.
My intuition tells me I doubt it. If I had to do this I would
consider using SWIG which I have used in another context
(not using serialization) to integrate Boost components into
.NET languages.

Robert Ramey

Damien Fisher wrote:
> I just tried compiling some source code in Microsoft VS 2005, with
> /clr turned on. It turned up the following error:
>
> boost/serialization/void_cast_fwd.hpp(26) : error C3389:
> __declspec(dllexport) cannot be used with /clr:pure or /clr:safe
>
> It appears that BOOST_DLLEXPORT, defined in
> boost/serialization/force_include.hpp, is always defined to
> __declspec(export). This is surely incorrect, is it not?
>
> The reason I bring this up is that it resolved a mysterious build
> "issue" I'd been having ever since I started using serialization
> (which occurs with native code generation on VC++): even though I
> only used serialization in an executable (i.e., the source got
> compiled to a .exe), the compiler was also producing an import library
> and export file, as it would for a DLL! I am guessing that this is
> due to the fact that functions are being "exported" from the
> executable via BOOST_DLLEXPORT. Sure enough, if I removed
> serialization from my source code, the exp and lib files disappeared.
>
> While this might only be slightly annoying, I can't help but think
> that the semantics of __declspec(dllexport) within a non-DLL are
> undefined at best. I don't know enough about the serialization
> library to understand this problem in enough detail to offer an
> alternative.
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


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