61

This is my warning.

implicit declaration of function 'exit'

How i can remove it.

i am using linux & gcc compiler.

ambika
  • 1,643
  • 5
  • 19
  • 18

3 Answers3

137

Add:

#include <stdlib.h>

to the top of your program.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 1
    @Greg Hewgill: In my program, I have not used `#include ` and I am getting this warning only when I use `-Wall` option. Otherwise the program compiles fine and executable runs properly. This means that gcc is somehow able to link to the file without my including it. How is that happening? – Lazer May 06 '10 at 16:13
  • 2
    @eSKay: Implicit declarations are *permitted* in C unless you use the `-Wmissing-protypes` warning switch (which is turned on by `-Wall`). – Greg Hewgill May 06 '10 at 19:17
12

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

#include <stdlib.h>
shinkou
  • 5,138
  • 1
  • 22
  • 32
2

exit() is a library function, the respecive prototypes are present in the stdlib.h header file, inoder to call the process to specified code for exit function, you need to attach the as #include stdlib.h header 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:

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.

prashad
  • 107
  • 2
  • 15