In a Jupyter notebook with the ROOT kernel, I’m trying to pass a list of string values which was generated in a Python cell to a cpp function in a cell marked %%cpp. I tried (just to see if it might work by chance) defining the cpp function as
void func(char** lst, int lst_size)
and
void func(vector<string> lst)
but in both cases I get the ‘could not convert argument 1’ exception.
What’s the correct way to do it?
Next time, you might want to fence your code with triple back quotes (```), which makes it a code block and conserves whitespace and applies syntax highlighting:
import ctypes
def call_c(L):
arr = (ctypes.c_char_p * len(L))()
arr[:] = [x.encode('utf-8') for x in L]
ROOT.func(len(L), arr)