Hi all-
I've been having trouble with getting a class with a std::complex<double> member to properly serialize. I've been searching all the documentation and the forums and I can't find a solution, but I think I may be doing something wrong.
This is with ROOT 5.26.00 on a linux x86_64, though I have seen similar issues on mac os x, ppc, with ROOT 5.24.00.
I have a class with a std::complex member:
Test.hh:
#include “TObject.h”
#include
#include
#ifndef Test_hh
#define Test_hh
class Test: public TObject
{
public:
std::complex<double> fMyComplexVector;
ClassDef(Test, 0);
};
#endif /* Test_hh */
Test.cc:
#include “Test.hh”
ClassImp(Test)
Now when I load the shared library associated with this class and try to write it to disk, I get different errors depending upon my LinkDef.h
---------First error----------
LinkDef.h:
#ifdef CINT
#pragma link C++ class Test+;
#endif
Script, test.C:
{
gSystem.Load(“libtest.so”);
aTest = new Test();
temp_file = new TFile(“temp.root”, “recreate”);
aTest->Write(“test”);
temp_file->Close();
}
yields:
Error in TClass::BuildRealData: Cannot find any ShowMembers function for complex!
Initially, I thought this was because I wasn’t building a dictionary with I/O enabled for std::complex (but I thought this was already precompiled?) which lead me to my second error:
---------Second error----------
LinkDef.h:
#ifdef CINT
#pragma link C++ class std::complex+;
#pragma link C++ class Test+;
#endif
Building this yields the warning:
Note: Link requested for already precompiled class complex (ignore this message) :0:
which I initially ignored as it said , but then running the same test script as above yielded:
Processing test.C…
Fatal: sizeof(::complex) == sizeof(::ROOT::Shadow::complexlEdoublegR) violated at line 61 of `testDICT.C’
aborting
Followed by a stack trace initiated by the assert.
Two questions:
- Am I doing something wrong in my LinkDef.h, or perhaps do I need to generate a custom ShowMembers?
- If not, and this is a current limitation in rootcint, is there a workaround? I.e. can I somehow wrap std::complex to use ROOT I/O with it?
I’ve included a test suite here that will compile the test code and run the test script automatically:
Just untar and type make
. To generate the different issues, the included LinkDef.h can be modified.
Thanks, and I hope everyone is having a great holiday!
Mike
test.tar.gz (1.16 KB)