# STL collection object in TFile not compatible across OSX and Linux

**URL:** <https://root-forum.cern.ch/t/stl-collection-object-in-tfile-not-compatible-across-osx-and-linux/60321>\
**Category:** ROOT\
**Tags:** bug, root\
**Created:** [July 25, 2024, 2:24pm UTC](https://root-forum.cern.ch/t/stl-collection-object-in-tfile-not-compatible-across-osx-and-linux/60321 "2024-07-25T14:24:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpuccio](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/c37758/32.png) [@mpuccio](https://root-forum.cern.ch/u/mpuccio)\
**Post date:** [July 25, 2024, 2:24pm UTC](https://root-forum.cern.ch/t/stl-collection-object-in-tfile-not-compatible-across-osx-and-linux/60321/1 "2024-07-25T14:24:55Z")

</div>

Hello,  
I was trying to store a `std::vector<std::array<ULong64_t, 2>>` in a TFile and everything works perfectly when I read and write from my mac (I am on Sonoma with a M3 mac). Here an example code:

```cpp
#include <array>
#include <iostream>
#include <vector>

#include "TFile.h"

#pragma link C++ class std::vector<std::array<ULong64_t, 2>>+ ;

void writeVector() {
  std::vector < std::array < ULong64_t, 2>> test { { 1ull, 2ull }, { 3ull, 4ull }, { 5ull, 6ull } };
  TFile f("test.root", "RECREATE");
  f.WriteObject(&test, "test");
  f.Close();
}

void readVector() {
  TFile f("test.root");
  auto test = f.Get<std::vector<std::array < ULong64_t, 2> > >("test");

  for (auto &a: *test) {
    std::cout << a[0] << " " << a[1] << std::endl;
  }
  f.Close();
}

```

If I try to read from a Linux machine (x86-64) the same file I get the following error:

```auto
Error in <TBufferFile::ReadVersion>: Could not find the StreamerInfo with a checksum of 0x44178e08 for the class "array<ULong64_t,2>" in test.root.
Error in <TBufferFile::CheckByteCount>: object of class array<ULong64_t,2> read too few bytes: 6 instead of 22
Error in <TBufferFile::ReadVersion>: Could not find the StreamerInfo with a checksum of 0x44178e08 for the class "array<ULong64_t,2>" in test.root.
Error in <TBufferFile::CheckByteCount>: object of class array<ULong64_t,2> read too few bytes: 6 instead of 22
Error in <TBufferFile::ReadVersion>: Could not find the StreamerInfo with a checksum of 0x44178e08 for the class "array<ULong64_t,2>" in test.root.
Error in <TBufferFile::CheckByteCount>: object of class array<ULong64_t,2> read too few bytes: 6 instead of 22

```

If I try to create the same test.root file on Linux and then read it on the mac, I get the same error.  
We tried with a colleague to read the test.root produced on the ARM mac on a Intel mac and it works.  
Is there something I am missing to make these objects readable across operating systems?  
I am using on both machines ROOT 6.30/01 (with ALICE patches).

Cheers,  
Max

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [July 25, 2024, 3:02pm UTC](https://root-forum.cern.ch/t/stl-collection-object-in-tfile-not-compatible-across-osx-and-linux/60321/2 "2024-07-25T15:02:03Z")

</div>

adding @pcanal to the loop

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 8, 2024, 3:02pm UTC](https://root-forum.cern.ch/t/stl-collection-object-in-tfile-not-compatible-across-osx-and-linux/60321/3 "2024-08-08T15:02:58Z")

</div>

Closed on August 8, 2024, 3:02pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<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:** [December 6, 2024, 5:23pm UTC](https://root-forum.cern.ch/t/stl-collection-object-in-tfile-not-compatible-across-osx-and-linux/60321/4 "2024-12-06T17:23:06Z")

</div>

`std::vector<std::array < ULong64_t, 2> > ` is not currently supported. Use:

```auto
struct ArrayWrapper // This could of course be a template
{
    std::array < ULong64_t, 2> fArray;
};

```

and  
`std::vector<ArrayWrapper>`  
and of course you need to generate a dictionary for both `ArrayWrapper` and the dictionary.
