# Illegal Pointers and Interpreting ROOT error codes

**URL:** <https://root-forum.cern.ch/t/illegal-pointers-and-interpreting-root-error-codes/32880>\
**Category:** Newbie\
**Tags:** tree\
**Created:** [February 24, 2019, 5:03am UTC](https://root-forum.cern.ch/t/illegal-pointers-and-interpreting-root-error-codes/32880 "2019-02-24T05:03:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marisa\_P](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marisa_p/32/20288_2.png) [@Marisa\_P](https://root-forum.cern.ch/u/Marisa_P)\
**Post date:** [February 24, 2019, 5:03am UTC](https://root-forum.cern.ch/t/illegal-pointers-and-interpreting-root-error-codes/32880/1 "2019-02-24T05:03:59Z")

</div>

Hello, many times in my work I will see the following error code:

`Error: illegal pointer to class object infile 0x0 5 GEM_zoffset.cpp:35:`

The lines of code in question are

```auto
TString * s_infile = Form("histograms_run%d.root",nofile);
TFile * infile = TFile:Open(s_infile, "READ");
//TFile infile("histograms_run1483.root");
 
TTree * t_hits = infile.Get("T_hits");
//TTree * t_hits = (TTree*)infile->Get("T_hits");
//TTree * t_hits; gDirectory->GetObject("T_hits",t_hits);

```

I’ve used this method of reading a ROOT tree in many codes, but this time it just won’t compile. The only difference with this file is that these lines are written above the main program, whereas usually they’re written within the main program’s brackets.

I was wondering if a) Someone might know what I’m doing wrong, and/or b) Where I can find error code documentation so I can understand the numbers `0x0 5`?

Thank you very much!

---

<div class="post-metadata">

**Author:** ![Triple\_S](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/triple_s/32/17129_2.png) [@Triple\_S](https://root-forum.cern.ch/u/Triple_S)\
**Post date:** [February 24, 2019, 6:08am UTC](https://root-forum.cern.ch/t/illegal-pointers-and-interpreting-root-error-codes/32880/2 "2019-02-24T06:08:38Z")

</div>

You declare your TString s\_infile as a pointer. This is possible, but then you have to treat it like a pointer of course. In your code just remove the \* after TString and it should work.

---

<div class="post-metadata">

**Author:** ![Marisa\_P](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/marisa_p/32/20288_2.png) [@Marisa\_P](https://root-forum.cern.ch/u/Marisa_P)\
**Post date:** [February 24, 2019, 7:03am UTC](https://root-forum.cern.ch/t/illegal-pointers-and-interpreting-root-error-codes/32880/3 "2019-02-24T07:03:34Z")

</div>

Wow, what a silly mistake. Thank you!
