编译时收到以下警告:
execute.c:20:2: warning: implicit declaration of function ‘execvpe’[-Wimplicit-function-declaration] execvpe("ls", args, envp);
^
我的理解是,当您尝试使用的函数具有不正确的参数类型时,就会发生这种情况。但是,我很确定我提供了正确的论点:
int execvpe(const char *file, char *const argv[], char *const envp[]);
以下是我的代码的相关部分:
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
void test_execvpe(char* envp[])
{
const char* temp = getenv("PATH");
char path[strlen(temp)+1];
strcpy(path, temp);
printf("envp[%d] = %s\n", 23, envp[23]); //print PATH
char* args[] = {"-l", "/usr", (char*) NULL};
execvpe("ls", args, envp);
}
int main( int argc, char* argv[], char* envp[])
{
//test_execlp();
test_execvpe(envp);
return 0;
}
任何人都知道为什么我不断收到这个错误?谢谢!