dimanche 29 mars 2015

how initialize char* const argv [] in c++


An API function takes an argument of type 'char *const argv[]' I am initializing this type of arguments in my c++ application like:



char* const argv[] = {"--timeout=0", NULL};


and passing the arguments to API function like:



Spawner spawner;
spawner.execute (argv, true);


using g++ compiler, I am getting following Error:



error: deprecated conversion from string constant to 'char*' [-Werror=write-strings]


how can I get rid of above error?


Below is the declaration of execute function in API:



void Spawner::execute (char *const argv[], bool bShowChildWindow)



Aucun commentaire:

Enregistrer un commentaire