I am using boost::python to integrate Python into a C ++ program. Now, I would like a Python program executed with boost::python::exec_file() to be able to get the command line arguments of my C ++ program via sys.argv . Is it possible?
boost::python
boost::python::exec_file()
sys.argv
Before your call exec_file() (but after Py_Initialize() you must call PySys_SetArgv(argc, argv); , providing it to int argc and const char *argv[] from your program main() .
exec_file()
Py_Initialize()
PySys_SetArgv(argc, argv);
int argc
const char *argv[]
main()