I am trying to bind python3 in C++.
When using this:
Py_SetProgramName(argv[0]);
it gives this error:
error C2664: 'Py_SetProgramName' : cannot convert parameter 1 from 'char *' to 'wchar_t *'
Even though that's how the documentation example shows to do it.
I also tried this:
Py_SetProgramName((wchar_t*)argv[0]);
But apparently that's the wrong way to do it.
So how do I fix this, and is there any other good resources on binding Python 3 in C++?
The official way of converting from char to wchar_t is now :
wchar_t *program = Py_DecodeLocale(argv[0], NULL);
Py_SetProgramName(program);
on a side note mbstowcs is not reliable on some platforms.
A quite good example of using python2/3 with c++ would be Panda3D. a c++ game engine scripted with python, that also provides a c++ module builder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With