Issue
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.
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));
}
Answered By - Pietro Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.