Dear experts,
when using the interpreter, C++ std symbols pollute the namespace, even if I set Rint.Includes: 0
in .rootrc
.
An example:
root [0] int data = 1
(int) 1
root [1] data = 2
ROOT_prompt_1:1:1: error: reference to 'data' is ambiguous
data = 2
^
ROOT_prompt_0:1:5: note: candidate found by name lookup is '__cling_N50::data'
int data = 1
^
/usr/include/c++/11/bits/range_access.h:319:5: note: candidate found by name lookup is 'std::data'
data(initializer_list<_Tp> __il) noexcept
^
/usr/include/c++/11/bits/range_access.h:290:5: note: candidate found by name lookup is 'std::data'
data(_Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/11/bits/range_access.h:300:5: note: candidate found by name lookup is 'std::data'
data(const _Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/11/bits/range_access.h:310:5: note: candidate found by name lookup is 'std::data'
data(_Tp (&__array)[_Nm]) noexcept
^
root [2] __cling_N50::data
(int) 1
Prefixing __cling_N50::
every time is really cumbersome, not to mention that the specific __cling
namespace changes during the interactive session.
However, this is even worse if a C++ name is used as name for a TNamed-derived object:
root [0]
Attaching file Rates_V0_flux.root as _file0...
(TFile *) 0x556c10f0ab20
root [1] .ls
TFile** Rates_V0_flux.root
TFile* Rates_V0_flux.root
KEY: TTree data;1
KEY: TNtuple bins;1
root [2] data
ROOT_prompt_2:1:1: error: reference to overloaded function could not be resolved; did you mean to call it?
data
^~~~
/usr/include/c++/11/bits/range_access.h:290:5: note: possible target for call
data(_Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/11/bits/range_access.h:300:5: note: possible target for call
data(const _Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/11/bits/range_access.h:310:5: note: possible target for call
data(_Tp (&__array)[_Nm]) noexcept
^
/usr/include/c++/11/bits/range_access.h:319:5: note: possible target for call
data(initializer_list<_Tp> __il) noexcept
^
root [3] bins
(TNtuple *) 0x556c10cd9c40
Now the TTree data
is not available at all, the only way of using it is to do auto t = gFile->Get<TTree>("data")
.
In previous versions of ROOT (like 6.20), I had similar problems with variable names like y
, but I never had problems with TTrees called data
.
Best,
Claudio
ROOT Version: 6.26/02
Git Revision: c8d49336
Platform: Ubuntu
Compiler: gcc