# Base class has no streamer or dictionary

**URL:** <https://root-forum.cern.ch/t/base-class-has-no-streamer-or-dictionary/54876>\
**Category:** Newbie\
**Created:** [May 16, 2023, 1:46pm UTC](https://root-forum.cern.ch/t/base-class-has-no-streamer-or-dictionary/54876 "2023-05-16T13:46:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ireid](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/i/8c91f0/32.png) [@ireid](https://root-forum.cern.ch/u/ireid)\
**Post date:** [May 16, 2023, 1:46pm UTC](https://root-forum.cern.ch/t/base-class-has-no-streamer-or-dictionary/54876/1 "2023-05-16T13:46:23Z")

</div>

* * *

\_ROOT Version: 6.24/07  
\_Platform: CentOS 7  
\_Compiler: gcc version 10.3.0 (GCC)

* * *

```
We are trying to understand why we get the error message

```

“ap\_int\_base\<36,false\>: base class ssdm\_int\_sim\<36,false\> has no streamer or dictionary it will not be saved”  
when we try to save our custom classes to file.

```
 Background: We are developing FPGA code for the CMS trigger, using

```

Vitis HLS (High Level Synthesis) which, in theory, allows the same C++ code  
to create the FPGA payload and also to simulate the result within the CMSSW  
framework. We use headers for arbitrary-precision integers provided by Xilinx:  
[GitHub - Xilinx/HLS\_arbitrary\_Precision\_Types](https://github.com/Xilinx/HLS_arbitrary_Precision_Types) with a “local” copy at  
/cvmfs/cms.cern.ch/slc7\_amd64\_gcc10/external/hls/2019.08-80454731218d87c9edf8f512cb8429f9/include

```
The error given above puzzles us, because while it's true that class

```

ssdm\_int\_sim does not have streamers (by which I understand overloads for  
stream operators \>\> and \<\<, to allow serialisation/deserialisation) the  
derived class ap\_int\_base does, e.g.

INLINE std::ostream& operator\<\<(std::ostream& os,  
const ap\_int\_base\<\_AP\_W, \_AP\_S\>& x) {  
std::ios\_base::fmtflags ff = std::cout.flags();  
if (ff & std::cout.hex) {  
os \<\< x.to\_string(16); // don’t print sign  
} else if (ff & std::cout.oct) {  
os \<\< x.to\_string(8); // don’t print sign  
} else {  
os \<\< x.to\_string(10);  
}  
return os;  
}

```
These overloads do seem to work on "normal" code, viz.

```

[eesridr:test] \> cat test2.cc  
#include   
#include   
#include “ap\_int.h”

int main() {

ap\_int\<36\> A{255}, B{0};  
ap\_int\_base\<36, false\> C{1000}, D{0};

std::ofstream ofs;  
ofs.open (“testout.bin”, std::ofstream::out | std::ofstream::trunc);

ofs \<\< A \<\< " " \<\< C;  
ofs.close();

std::ifstream ifs;  
ifs.open (“testout.bin”, std::ifstream::in );  
ifs \>\> B \>\> D;  
ifs.close();

std::cout \<\< B \<\<" “\<\< D \<\<”\n";

return 0;  
}

[eesridr:test] \> g++ -I/cvmfs/cms.cern.ch/slc7\_amd64\_gcc10/external/hls/2019.08-80454731218d87c9edf8f512cb8429f9/include testh.cc  
[eesridr:test] \> ./a.out  
255 1000

```
 So, why does this not work in ROOT? Why does it look to the base class

```

for the streamers?

```
Thanks,
	ivan

```

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [May 16, 2023, 2:12pm UTC](https://root-forum.cern.ch/t/base-class-has-no-streamer-or-dictionary/54876/2 "2023-05-16T14:12:01Z")

</div>

> [@ireid](#):
>
> by which I understand overloads for  
> stream operators \>\> and \<\<, to allow serialisation/deserialisation

ROOT does not use those for serialization (for example they would not support splitting in independent column nor automatic schema evolution). Instead we use the C++ introspection provided by Cling (leveraging clang).

In the CMSSW context, to generate dictionary you need to have a [selection.xml](https://root.cern.ch/root/htmldoc/guides/users-guide/AddingaClass.html#genreflex-a-comfortable-interface-to-rootcling) and update the build system to request its use for building.

---

<div class="post-metadata">

**Author:** ![ireid](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/i/8c91f0/32.png) [@ireid](https://root-forum.cern.ch/u/ireid)\
**Post date:** [May 25, 2023, 10:39am UTC](https://root-forum.cern.ch/t/base-class-has-no-streamer-or-dictionary/54876/3 "2023-05-25T10:39:59Z")

</div>

@pcanal In the CMSSW context, to generate dictionary you need to have a [selection.xml](https://root.cern.ch/root/htmldoc/guides/users-guide/AddingaClass.html#genreflex-a-comfortable-interface-to-rootcling) and update the build system to request its use for building.

OK, it turns out we do have a classes.h and a classes\_def.xml, and build a dictionary /tmp/L1TriggerDataFormats\_TrackFindingTrackletHLS\_xr.cc when compiling. This includes three classes that I had to add to the .xml file to remove original errors:

```auto
grep 'ap_' /tmp/L1TriggerDataFormats_TrackFindingTrackletHLS_xr.cc | grep namespace
} // end of namespace ROOT for class ::ap_uint<36>
} // end of namespace ROOT for class ::ap_uint<7>
} // end of namespace ROOT for class ::ap_private<36,false,true>

```

So this still leaves the question of why it wants a dictionary for class ssdm\_int\_sim\<36,false\>, or how we force compilation to build it.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [May 25, 2023, 12:18pm UTC](https://root-forum.cern.ch/t/base-class-has-no-streamer-or-dictionary/54876/4 "2023-05-25T12:18:26Z")

</div>

The original message indicates that one is try to store (directly or indirectly) an object of type `ap_int_base<36,false>` in a ROOT file. In order to store that kind of object, ROOT needs to know about each of its components so that it can store those as part of the `ap_int_base<36,false>` object. The error message indicates that the base class `ssdm_int_sim<36,false>` is one of those components and thus needs a dictionary.

---

<div class="post-metadata">

**Author:** ![ireid](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/i/8c91f0/32.png) [@ireid](https://root-forum.cern.ch/u/ireid)\
**Post date:** [June 9, 2023, 1:12pm UTC](https://root-forum.cern.ch/t/base-class-has-no-streamer-or-dictionary/54876/5 "2023-06-09T13:12:30Z")

</div>

Thanks. Your message prompted me to review our build process. I’d gone off on a tangent when adding ssdm\_int\_sim\<36,false\> led to segment failure. When I added ap\_int\_base\<36,false\> as well, the segfail went away, and I was then able to iterate execution finding each of several other classes that needed to be added to classes\_def.xml until there were no more failures. Now I’m able to save the objects from the second of three steps, and successfully run just the third step on the resultant file. Thanks again for leading me back down the correct rabbit-hole.
