Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for boost serialization #34

Closed
wants to merge 1 commit into from
Closed

Fix for boost serialization #34

wants to merge 1 commit into from

Conversation

efp
Copy link

@efp efp commented May 29, 2018

When compiling with boost serialization versions 1.60.0 and up, one will
get an error that boost can't access the memblock destructor. This adds
the required friend statement for boost.

When compiling with boost serialization versions 1.60.0 and up, one will
get an error that boost can't access the memblock destructor. This adds
the required friend statement for boost.
@slayoo
Copy link
Member

slayoo commented May 30, 2018

Thank you! Let me keep it open for a few days and add a new Boost example to the continuous integration build beforehand so the fix would then also be exemplified.

@efp
Copy link
Author

efp commented May 30, 2018

I tried this program

#define BZ_HAVE_BOOST_SERIALIZATION

#include <blitz/array.h>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>

#include <iostream>
#include <sstream>

int main()
{
    std::stringstream ss ;
    
    blitz::TinyVector<int, 3> dims{1,1,1} ;
    blitz::Array<float, 3> array(dims) ;
    array(0,1,0) = 3 ;
    
    boost::archive::text_oarchive oa(ss);
    oa << array ;
    
    std::cout << ss.str() << std::endl ;
    
    ss.seekg(0) ;
    blitz::Array<float, 3> array2(dims) ;    
    boost::archive::text_iarchive ia(ss);
    
    ia >> array2 ;
    
    std::cout << array2(0,1,0) << std::endl ;
}

On Ubuntu 18.04 gcc 7.3.0

g++ -o bstest -I. -lblitz bstest.cpp -lboost_serialization

Before fix:

/usr/local/include/boost/archive/detail/iserializer.hpp:246:17: error: ‘blitz::MemoryBlock<P_type>::~MemoryBlock() [with P_type = float]’ is protected within this context

After the fix, builds and runs with output:

22 serialization::archive 15 0 0 0 0 2 1 0
0 1 0.000000000e+00 0 0 0 3 1 1 1 0 0 0 0 0 3 1 1 1 3 2 1 0 3 0 0 0 0 0 3 1 1 1 0
0

Ok, that last number isn't right... I never tried it with a stringstream before.

Oddly, it fails to link with boost serialization unless I put the -lboost_serialization after the cpp file name.

Also note, the error only occurs when using the input archive; I tried it first with only the output archive and it compiled.

@slayoo
Copy link
Member

slayoo commented May 30, 2018

thank you!

@citibeth
Copy link
Contributor

@slayoo Can we merge this?

@slayoo
Copy link
Member

slayoo commented Mar 3, 2019

As above, I vote for adding at least a minimalistic test case

@efp
Copy link
Author

efp commented May 18, 2020

Since this fixes a compilation error, it doesn't seem amenable for addition to the test suite.

slayoo added a commit that referenced this pull request May 24, 2020
@slayoo
Copy link
Member

slayoo commented May 24, 2020

Sorry, here's a PR that should hopefully fix the merge conflict: #165

slayoo added a commit that referenced this pull request May 24, 2020
@slayoo
Copy link
Member

slayoo commented May 24, 2020

merged, thank you!

@slayoo slayoo closed this May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants