This simple snippet generates the “missing sentinel in function call” warning with g++ 4.7.0, both if compiled as Cand C++ source. I believe that it’s an error of the compiler, as the final NULL value is there.
#include <unistd.h>
int main() {
execlp("mkdir", "mkdir", "-p", "test", NULL);
return 0;
}
Am I right?
No, you’re wrong.
In C++ NULL is something like
0or0Land might be the same in C. If the type of that constant is smaller than a pointer then it is not safe to pass it to a variadic function, as the high bits will be filled with junk.On Linux the
execlp(1)man page says:i.e. to portably provide the sentinel you need to do:
and this is what GCC is warning you about.