GCC will help you warn you if you forget to turn on the NULL watch at the end of a call to one of the exec (3) functions
#include <unistd.h>
int main(int argc, char **argv)
{
execlp("test", "test", "arg1");
}
Example compiler output for GCC 4.8:
$ g++ test.cc -Wformat
test.cc: In function ‘int main(int, char**)’:
test.cc:4:32: warning: missing sentinel in function call [-Wformat=]
execlp("test", "test", "arg1");
^
$
However, if you compile in C ++ 11 mode, the diagnostics will not print:
$ g++ test.cc -std=c++11 -Wformat
$
Why is this warning not available in C ++ 11? Is there any way to get it back?
source
share