My work consists of four CPP files, with two of them involving mutual function calls. In dep.cpp, the onStart function calls the show function in the dog.cpp file. When using cling::Interpreter to declare these CPP files successively (declare dep.cpp first and then declare dog.cpp), how can the issue of the show() function’s logic not being executed when the onStart function is executed be resolved?
I don’t think this has really anything to do with ROOT or cling. Also, you don’t have any circular dependency in your logic. You are just missing some implementation details
#ifndef DOG
#define DOG
struct Dog{
void show();
};
#endif // DOG
main.cpp
#include "dep.hpp"
int main(){
Dep d;
d.onStart();
}
Then you can just compile the main program with its dependencies and you’ll see the right output. Again, no ROOT and no interpreter here, just standard C++ code and some compiler knowledge.
Thank you very much for your reply.
The problem I encountered is that there are interdependent functions in the input passed to the cling::Interpreter::declare(const std::string& input, Transaction** T/*=0 /) function many times, resulting in abnormal running results .
Later I switched to cling::Interpreter::parse(const std::string& input,
Transaction* T = 0), the problem is solved, don’t care about the interdependence between inputs.