If a variable is declared as:
char ** argv;
And a function's definition is something like:
extern int my_system(const char *argv[]);
Now if we are passing the argument in the function as:
(my_system(argv))
then it throws the warning passing argument 1 of 'my_system' from incompatible pointer type.
What can be the possible solution to this?
In C, there is no implicit conversion between T**
to const T**
, because it would not prevent modification of ultimate element in all cases. See C FAQ's question 11.10
for enhanced explanation and example of "backdoor" modification.
In your case, gained understanding of intricacies, you could cast the pointer to silent the warning:
extern int my_system(const char *argv[]);
int main(int argc, char* argv[])
{
my_system((const char**)argv);
}