I am working on MacOS-X Lion with GCC 4.2. This code works, but I get a warning I would like fix:
#include <unistd.h>
main()
{
char *args[] = {"/bin/ls", "-r", "-t", "-l", (char *) 0 };
execv("/bin/ls", args);
}
warning: deprecated conversion from string constant to 'char*'
I do not want the warning to be suppressed, I want not to have it at all. It is C++ code, not C.
Using a char *const (so exactly the type required by execv()) still produces the warning.
Thank you.
This seems to be ok:
#include <unistd.h>
main()
{
char const *args[] = {"/bin/ls", "-r", "-t", "-l", NULL };
execv("/bin/ls", const_cast<char**>(args));
}
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