C语言 C警告隐式声明函数'exit'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2406986/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 04:46:51  来源:igfitidea点击:

C warning implicit declaration of function 'exit'

cgcc-warning

提问by ambika

This is my warning.

这是我的警告。

implicit declaration of function 'exit'

How i can remove it.

我怎样才能删除它。

i am using linux & gcc compiler.

我正在使用 linux 和 gcc 编译器。

回答by Greg Hewgill

Add:

添加:

#include <stdlib.h>

to the top of your program.

到你的程序的顶部。

回答by shinkou

Do you have this preprocessor? If not, add it.

你有这个预处理器吗?如果没有,请添加它。

#include <stdlib.h>

回答by prashad

exit() is a library function, the respecive prototypes are present in the stdlib.hheader file, inoder to call the process to specified code for exit function, you need to attach the as #include stdlib.hheader in your program. that is the reason we should add the stdlib.h header. eventhough you can run the program, but it shows the warning message like below:

exit() 是一个库函数,各自的原型存在于stdlib.h头文件中,为了将进程调用到指定的退出函数代码,您需要在程序中附加as #include stdlib.h头文件。这就是我们应该添加 stdlib.h 头文件的原因。尽管您可以运行该程序,但它会显示如下警告消息:

warning: incompatible implicit declaration of built-in function ‘exit' [enabled by default]      

but, this kind of program not recommended, we need to take care of what we are given in the program,be cautious. warning may leads runtime error.

但是,不推荐这种程序,我们需要注意程序中给出的内容,要谨慎。警告可能会导致运行时错误。