How to use execv() without warnings?
c++, execv, g++, macos, warnings
Solution
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));
}
Problem
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.