Errors if rerunning macro within same cint session

Hi,

I like to run simple macros directly within the CINT interpreter, and rather often while in development phase. However, when using functions from c++ standard library, I get errors when running a macro two (or more) times within the same CINT session. This is something really annoying because I need to quit and restart the session every time I want to rerun the macro…

For example, for the macro below:

#include <sstream>
#include <string>
using namespace std;

void test(){
  istringstream is("a,e,i,o,u");
  string st;

  while(getline(is,st,','))
    cout << st << endl;
}

this is the output when run two times in a row within the same session:

root [0] .x test.C
a
e
i
o
u
root [1] .x test.C
In file included from input_line_13:1:
/Users/sevilla/cernbox/Documents/UNIGE/TEACHING/COURS/Electronics/WORK/macros/scope/test.C:8:17: error: no matching constructor for initialization of 'std::__1::istringstream' (aka 'basic_istringstream<char>')
  istringstream is("a,e,i,o,u");
                ^  ~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/iosfwd:120:32: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const char [10]' to 'const std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >' for 1st argument
    class _LIBCPP_TEMPLATE_VIS basic_istringstream;
                               ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/sstream:649:14: note: candidate constructor not viable: no known conversion from 'const char [10]' to 'ios_base::openmode' (aka 'unsigned int') for 1st argument
    explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
             ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/sstream:655:5: note: candidate constructor not viable: no known conversion from 'const char [10]' to 'std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >' for 1st argument
    basic_istringstream(basic_istringstream&& __rhs);
    ^

ROOT Version: 6.22/08
Platform: macosx64, x86_64-apple-darwin18.7.0
Compiler: clang version 11.0.0 (clang-1100.0.33.17)


CINT is old and is now replaced by Cling. Nevertheless I ran you example with ROOT 6 (ie Clling) and I see a similar error. It runs fine the 1st time and produces errors the 2nd time. @axel or @vvassilev should know why.

@couet this was ROOT 6’s cling in the original post, as visible in

ROOT Version: 6.22/08

@segonzal that’s a known, really tough issue: we are aware of several cases where reloading the code fails, e.g. Loading... Loading... .

I see two options: fix these cases as they occur, or find a more fundamental solution. @vvassilev @pcanal @jalopezg opinions?

Hi all,

Yes, I am aware of several open tickets on this. I took a quick look to this in December, but I jumped to work in something else. IMO, I should definitely dedicate some time after easter to fix all unloading-related issues. What do you think, @Axel, @vvassilev?

Cheers.

I think that’d be great, but I’d also think we should brainstorm alternatives :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.