Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot convert ‘char**’ to ‘wchar_t**’

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?

like image 428
user1561108 Avatar asked Feb 12 '26 07:02

user1561108


2 Answers

You could look into whether your compiler supports wmain. If so, you can replace main with:

int wmain(int argc, wchar_t *argv[])
{  
    PySys_SetArgv(argc, argv);
like image 103
M.M Avatar answered Feb 14 '26 20:02

M.M


Refer to the following link:

how to convert char array to wchar_t array?

You can write a conversion routine:

#include <iostream>
#include <stdlib.h>
#include <string>

using namespace std;
using namespace System;


int main(int argc, char* argv[])
{
    char *orig = "Hello, World!";
    cout << orig << " (char *)" << endl;

    // Convert to a wchar_t*
    size_t origsize = strlen(orig) + 1;
    const size_t newsize = 100;
    size_t convertedChars = 0;
    wchar_t wcstring[newsize];
    mbstowcs_s(&convertedChars, wcstring, origsize, orig, _TRUNCATE);
    wcscat_s(wcstring, L" (wchar_t *)");
    wcout << wcstring << endl;
}
like image 40
Bizkit Avatar answered Feb 14 '26 21:02

Bizkit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!