Rerunning root macro in an already active session


ROOT Version: 6.30/04
Platform: lxplus
Compiler: g++ 11.4.1


Hi all,
I run my root macro (see below) via root test.C works as expected. When however running it again from the root prompt with .x test.C, the following error is returned:

IncrementalExecutor::executeFunction: symbol '_ZSt7forwardIRKfEOT_RNSt16remove_referenceIS2_E4typeE' unresolved while linking [cling interface function]!
You are probably missing the definition of float const& std::forward<float const&>(std::remove_reference<float const&>::type&)
Maybe you need to load the corresponding shared library?

As I’m quite new to ROOT and C++ I’m not sure how to resolve this and any advice would be appreciated. My current work around is to quit the session and start a new one. Many thanks!

The macro:

#include <vector>

int test(){
    std::vector<float> dRs;
    float dR = 1.0;
    dRs.push_back(dR);
    return 1;
}

You can load the macro (.L) once and then run it as function every time. E.g. if your macro file is test.C:

root [0] .L test.C
root [1] test()
(int) 1
root [2] test()
(int) 1
root [3]

If you do changes to the macro after it’s already loaded, load it again.