Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] conflicting declaration(BOOST_CLASS_EXPORT)
From: jens weller (jensweller_at_[hidden])
Date: 2008-09-24 04:30:24


Jeff Flinn wrote:
> jens weller wrote:
>
>> Jeff Flinn wrote:
>>
>>> jens weller wrote:
>>>
>>>> Robert Ramey wrote:
>>>>
>>>>> try the following re export:
>>>>>
>>>>> a) re-read the manual regarding boost class export
>>>>
>>>>
>>>> I did, any points you think about?
>>>>
>>>>> b) Try using BOOST_CLASS_EXPORT only once.
>>>>
>>>>
>>>>
>>>> So far I thought after each class I could just set a
>>>> BOOST_CLASS_EXPORT($classname),
>>>> as far as its derived from a serializable class.
>>>> So, how to use it "only once"?
>>>> Should I put those all in one file instead? ("exportmodel.hpp" f.e.)
>>>
>>>
>>>
>>> Hi Jens,
>>>
>>> I think Robert means that BOOST_CLASS_EXPORT($classname) may only be
>>> expanded once in your program for a particular class name. And per
>>> the docs this expansion must occur within the context of all archive
>>> types that will be used to serialize the class.
>>>
>>> So rather than placing these macro calls in headers(which may be
>>> included in multiple translation units), place them in a cpp file
>>> that first includes the desired archive headers. Typically this would
>>> be in the class' implementation file. In the past I had placed them
>>> all in a single file, but quickly found the MSVC7.1 compiler limits,
>>> and had to break them up into export1.cpp, export2.cpp, ...
>>>
>>>
>>> Jeff Flinn
>>
>>
>> Unfortunately it does not work for me.
>>
>> "Die Anweisung "0x00411b4c" verweist auf Speicher in "0x000000000".
>> Der Vorgang "written" konnte nicht auf den Speicher durchgeführt werden."
>>
>> thats what I get as soon as I compile in Releasemode.
>> Debug Version runs without errors, so I guess the code is ok.
>>
>> My Export.cpp:
>>
>>
>> #include <boost/archive/text_oarchive.hpp>
>> #include <boost/archive/text_iarchive.hpp>
>> #include "Include.hpp"
>> #include "FileNode.hpp"
>> #include "DirNode.hpp"
>> #include "Observer.hpp"
>>
>> namespace codemodel
>> {
>> BOOST_CLASS_EXPORT( Include )
>> BOOST_CLASS_EXPORT( FileNode )
>> BOOST_CLASS_EXPORT( DirNode )
>> BOOST_CLASS_EXPORT( ParentNode )
>> //*/
>> }
>>
>> I'm using SVN Version of boost, about a week old.
>> I currently have no short example, but will try to get one working.
>> Anything wrong with this code?
>> Any hints why it fails in Releasemode?
>
>
> Could be the code is being stripped from the release build?
>
> Sorry, meine deutsche rostig ist. :-) so I'm not positive of the
> compile/link error your getting.
>
> Jeff

The program compiles. It crashes directly at start up. With write to
0x00000000, which I guess simply is an uninitialised pointer some where
in the guts of BOOST_CLASS_EXPORT.

As I said release -> crash, debug -> works fine.
Also removing the BOOST_CLASS_EXPORT Macros removes the crash. So I
doubt some how that this happens in my own code.

Also placing the B_C_E macros in the main file, makes it(partly) work
again, but thats no solution, and no explanation why it crashes if there
somewhere else. Also in my main program, this does not work.

I have a simple example, which I attach. I use MinGW under XP.

regards,

Jens Weller




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