root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.72k stars 1.3k forks source link

rootcling ignores RVec and RDataFrame #9920

Open vgvassilev opened 2 years ago

vgvassilev commented 2 years ago

cat LinkDef.h:

#ifndef LinkDef_h
#define LinkDef_h

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>

using namespace ROOT::VecOps;

#include "TwoInts.h"

#ifdef __CLING__
#pragma link C++ class TwoInts+;
#pragma link C++ class ROOT::VecOps::RVec<TwoInts>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<TwoInts>>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<int>>+;
#pragma link C++ class ROOT::VecOps::RVec<ROOT::VecOps::RVec<ROOT::VecOps::RVec<int>>>+;
#endif

#endif /* LinkDef_h */

TwoInts.h:

#ifndef TwoInts_h
#define TwoInts_h

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>

using namespace ROOT::VecOps;

struct TwoInts {
   int a, b;
};

#endif /* TwoInts_h */

ROOT version 6.24/06

rootcling -f mydict.cxx -rmf libmydict.rootmap -rml libmydict.so  LinkDef.h
clang++ -shared -o libmydict.so mydict.cxx `root-config --cflags —libs

The second command would fail with an error: no member named 'VecOps' in namespace ‘ROOT’ if LinkDef.h has includes, but TwoInts.h does not.

Is that a feature or a bug?

cc: @ianna

pcanal commented 2 years ago

Usually the syntax is

rootcling -f mydict.cxx -rmf libmydict.rootmap -rml libmydict.so  TwoInts.h LinkDef.h
vgvassilev commented 2 years ago

If we can't call rootcling without passing a header file next to the linkdef, we might be able diagnose this with the recent argument parsing implementation.

ianna commented 2 years ago

@pcanal - thanks, but adding the header to the command line still does not work if that header does not include:

#ifndef TwoInts_h
#define TwoInts_h

//#include <ROOT/RDataFrame.hxx>
//#include <ROOT/RVec.hxx>
//
//using namespace ROOT::VecOps;

struct TwoInts {
   int a, b;
};

#endif /* TwoInts_h */
% rootcling -f mydict.cxx -rmf libmydict.rootmap -rml libmydict.so  TwoInts.h LinkDef.h             
yana@iannas-macbook-pro AK-RDF % clang++ -mmacosx-version-min=11.6 -shared -o libmydict.so mydict.cxx `root-config --cflags --libs`                                          
mydict.cxx:56:70: error: no member named 'VecOps' in namespace 'ROOT'
   static TGenericClassInfo *GenerateInitInstanceLocal(const ::ROOT::VecOps::RVec<ROOT::VecOps::RVec<int> >*)
                                                             ~~~~~~~~^
mydict.cxx:56:89: error: no member named 'VecOps' in namespace 'ROOT'
   static TGenericClassInfo *GenerateInitInstanceLocal(const ::ROOT::VecOps::RVec<ROOT::VecOps::RVec<int> >*)
                                                                                  ~~~~~~^
mydict.cxx:56:105: error: expected '(' for function-style cast or type construction
   static TGenericClassInfo *GenerateInitInstanceLocal(const ::ROOT::VecOps::RVec<ROOT::VecOps::RVec<int> >*)
                                                                                                     ~~~^
mydict.cxx:56:107: error: expected ')'
   static TGenericClassInfo *GenerateInitInstanceLocal(const ::ROOT::VecOps::RVec<ROOT::VecOps::RVec<int> >*)
                                                                                                          ^
mydict.cxx:56:55: note: to match this '('
   static TGenericClassInfo *GenerateInitInstanceLocal(const ::ROOT::VecOps::RVec<ROOT::VecOps::RVec<int> >*)
                                                      ^
mydict.cxx:58:15: error: no member named 'VecOps' in namespace 'ROOT'
      ::ROOT::VecOps::RVec<ROOT::VecOps::RVec<int> > *ptr = 0;
      ~~~~~~~~^
mydict.cxx:58:34: error: no member named 'VecOps' in namespace 'ROOT'
      ::ROOT::VecOps::RVec<ROOT::VecOps::RVec<int> > *ptr = 0;
                           ~~~~~~^
...