Error with Readoptical.cpp

Dear Sir,

While compiling my program i am getting the following error.

ReadOptical.cpp:105:29: error: invalid use of incomplete type ‘class TKey’
  105 |          TString name =  key->GetName();
      |                             ^~
In file included from /home/saradindu/root/include/TTree.h:38,
                 from /home/saradindu/postdoc_genoa/lar-lenses/src/ReadOptical.cpp:1:
/home/saradindu/root/include/TDirectory.h:37:7: note: forward declaration of ‘class TKey’
   37 | class TKey;
      |       ^~~~
/home/saradindu/postdoc_genoa/lar-lenses/src/ReadOptical.cpp:109:38: error: invalid use of incomplete type ‘class TKey’
  109 |   int entries = ((TH2*)m_dir->Get(key->GetName()))->GetEntries();
      |                                      ^~

Please let me know what is the solution ?

with regards,
Saradindu

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Add #include "TKey.h" at the beginning of ReadOptical.cpp (or after #include "TTree.h")

Thank you. It works.

regards,
Saradindu

1 Like