C warning implicit declaration of function 'exit'

CGcc Warning

C Problem Overview


This is my warning.

implicit declaration of function 'exit'

How i can remove it.

i am using linux & gcc compiler.

C Solutions


Solution 1 - C

Add:

#include <stdlib.h>

to the top of your program.

Solution 2 - C

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

#include <stdlib.h>

Solution 3 - C

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 functionexit’ [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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionambikaView Question on Stackoverflow
Solution 1 - CGreg HewgillView Answer on Stackoverflow
Solution 2 - CshinkouView Answer on Stackoverflow
Solution 3 - CprashadView Answer on Stackoverflow