The code excerpt:
int main(int argc, char *argv[]){
PySys_SetArgv(argc, argv);
produces error message
error: cannot convert ‘char**’ to ‘wchar_t**’ for argument ‘2’ to ‘void PySys_SetArgv(int, wchar_t**)’
How do I convert argv
?
This API is part of python 3.0 and above and in my knowledge, there's no easy way to get this done. However, I think, you can try converting the argv
to a w_char **
and then call PySys_SetArgv()
. mbstowcs()
may come handy in this case.
For example, some pseudo-code (not tested) will look like
wchar_t **changed_argv;
changed_argv = malloc((argc)* sizeof*changed_argv);
for (int i = 0; i < argc, i++)
{
changed_argv[i] = malloc(strlen(argv[i]) + 1);
mbstowcs(changed_argv[i], argv[i], strlen(argv[i]) + 1);
}