Using TRint or gROOT to load a config.C file to configure an application

Hi @maurik,

You will have to pass the value of ptr instead, as in

   std::ostringstream oss;
   oss << ".x config.C(";
   oss << ptr;
   oss << ")";
   gROOT->ProcessLine(oss.str());

However, unless you have a specific reason for going this way (i.e., running a ROOT macro that changes the value of some members of a struct via a pointer), I would simply try to parse a JSON, which is less error-prone and should work if the dictionary for the given class is available.

Also, see this related topic: Reading a JSON file into ROOT C++ - #4 by linev.

Here is an example of this last option, if you want to try it (obviously the JSON string shall be read from a file):

struct Config {
   int i;
   float f;
   std::string s;
};
auto __config = TBufferJSON::FromJSON<Config>("{ \"i\": 1, \"f\": 1.234, \"s\": \"a string literal\"}");

Cheers,
J.