c - 即使在包含 <stdlib.h> 之后,'exit' 也会发出警告

标签 c linux header-files

即使在包含 <stdlib.h> 之后,我仍收到以下警告

warning: incompatible implicit declaration of built-in function ‘exit’

有人知道它为什么要捐赠吗?

void Check_file(char *filepath)
{
        if(access( filepath, F_OK ) == -1 ) {
                printf("\nUnable to access : %s\n",filepath);

                exit(1);
        }
        return;
}

最佳答案

您的程序 compiles without complaint当提供适当的包含文件时。

#include <stdio.h>              /* needed for printf */
#include <stdlib.h>             /* needed for exit */
#include <unistd.h>             /* needed for access and F_OK */
void Check_file(char *filepath)
{
        if(access( filepath, F_OK ) == -1 ) {
                printf("\nUnable to access : %s\n",filepath);

                exit(1);
        }
        return;
}
int main () { return 0; }

关于c - 即使在包含 <stdlib.h> 之后,'exit' 也会发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17674385/

相关文章:

php - 如何让 Symfony 启动进程 PID?

linux - 导入错误 : No module named 'libstdcxx' when starting Eclipse debugger

linux - Linux下的DMA和I/O内存区域

objective-c - 使用@class 访问委托(delegate)协议(protocol)声明

C++ std::vector 在头文件中初始化和设置

java - C,打开相对于可执行文件路径的文件?

c - 关于 char 数组和指向它们的指针,我错过了哪些语法

c - 为什么 'l' 和 'll' 修饰符对 printf 执行相同的操作 (C)

c - 如何在编译器中添加新的头文件位置

c - 中位数和众数不正确