Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/clingutils/src/complexLinkdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@

#pragma extra_include "root_std_complex.h";

#ifdef _WIN32
#pragma create TClass _C_float_complex+;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does remove the warnings by generating the dictionary but I think this results in files that are not readable on Linux. I.e. one might not be able to load the std::complex from the Windows produce file into the Linux std::complex object.

For example, contrast he output of:

TClass::GetClass("std::complex<int>")->GetStreamerInfo()->ls();

on both platform.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check

Copy link
Member Author

@bellenot bellenot Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here is the output on Windows:

C:\root-dev\build\x64\relwithdebinfo>root -l
root [0] TClass::GetClass("std::complex<int>")->GetStreamerInfo()->ls();

StreamerInfo for class: complex<int>, checksum=0x1bd95fcc
  _Complex_base<int,_Complex_value<int> > BASE            offset=  0 type= 0
  int            _real           offset=  0 type= 3
  int            _imag           offset=  4 type= 3
   i= 0, _Complex_base<int,_Complex_value<int> > type=  0, offset=  0, len=1, method=0
   i= 1, _real           type= 23, offset=  0, len=2, method=0 [optimized]
root [1]

I'll try on Linux once the build is over (on a VM with 4 cores...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Linux:

[bellenot@alma9-bb relwithdebinfo]$ root -l
root [0] TClass::GetClass("std::complex<int>")->GetStreamerInfo()->ls();

StreamerInfo for class: complex<int>, checksum=0x55a2a7c3
  int            _real           offset=  0 type= 3
  int            _imag           offset=  4 type= 3
   i= 0, _real           type= 23, offset=  0, len=2, method=0 [optimized]
root [1]

So if I understand correctly, this PR solves std::complex on Windows, but makes it incompatible with other platforms.
Then what do you suggest?

Copy link
Member Author

@bellenot bellenot Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcanal do you have any suggestion about how to possibly fix this? For example, with this PR, the following tests would pass:

C:\root-dev\build\x64\relwithdebinfo>ctest -C RelWithDebInfo -R roottest-root-io-complex
Test project C:/root-dev/build/x64/relwithdebinfo
    Start 1870: roottest-root-io-complex-classWithComplex-libgen-build
1/5 Test #1870: roottest-root-io-complex-classWithComplex-libgen-build ...   Passed    4.41 sec
    Start 1871: roottest-root-io-complex-writeClassWithComplex
2/5 Test #1871: roottest-root-io-complex-writeClassWithComplex ...........   Passed    1.13 sec
    Start 1872: roottest-root-io-complex-readClassWithComplex
3/5 Test #1872: roottest-root-io-complex-readClassWithComplex ............   Passed    1.10 sec
    Start 1873: roottest-root-io-complex-writecomplex
4/5 Test #1873: roottest-root-io-complex-writecomplex ....................   Passed    7.72 sec
    Start 1874: roottest-root-io-complex-readcomplex_WILL_FAIL
5/5 Test #1874: roottest-root-io-complex-readcomplex_WILL_FAIL ...........   Passed    7.78 sec

But obviously roottest-root-io-complex-readcomplex fails because of this incompatibility...

#pragma create TClass _Complex_base<float,_C_float_complex>+;
#pragma create TClass _C_double_complex+;
#pragma create TClass _Complex_base<double,_C_double_complex>+;
#pragma create TClass _Complex_value<int>+;
#pragma create TClass _Complex_value<long>+;
#pragma create TClass _Complex_base<int,_Complex_value<int>>+;
#pragma create TClass _Complex_base<long,_Complex_value<long>>+;
#endif

#pragma create TClass complex<int>+;
#pragma create TClass complex<long>+;
#pragma create TClass complex<float>+;
Expand Down
2 changes: 1 addition & 1 deletion roottest/root/io/newstl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ endif()
ROOTTEST_ADD_TEST(ComplexTest
MACRO runComplexTest.C
ROOTEXE_OPTS ${_complextest_load}
OUTREF ComplexTest${ref_suffix}
OUTREF ComplexTest.ref
FIXTURES_REQUIRED root-io-newstl-ComplexTest_h-fixture)

ROOTTEST_ADD_TEST(SampleFile
Expand Down
5 changes: 0 additions & 5 deletions roottest/root/io/newstl/ComplexTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ class Test: public TObject
ClassDefOverride(Test, 1);
};

#ifdef __ROOTCLING__
#pragma link C++ class std::complex<double>+;
#pragma link C++ class Test+;
#endif

#endif /* Test_hh */
8 changes: 0 additions & 8 deletions roottest/root/io/newstl/ComplexTest_win32.ref

This file was deleted.

8 changes: 0 additions & 8 deletions roottest/root/io/newstl/ComplexTest_win64.ref

This file was deleted.

Loading