On Fri, 3 Sep 2004 10:45:54 +0000 (UTC)
Darklight <ng********@netscape.net> wrote:
if the exit() function is contained in stdlid.h
why if i remove the above header file the exit
function still works and i can still compile
program without any error messages using cc file.c
if i use cc -Wall file.c i get error message
file.c:18: warning: implicit declaration of function `exit'
but program will still run and function properly
The exit function isn't contained in stdlib.h it is only declared there.
The actual function is either compiler magic of contained in the
standard library.
The warning when using -Wall is the compiler being helpful.
Please note that with some functions you invoke undefined behaviour if
you don't have an appropriate declaration in scope and there are real
systems where this can cause the software to fail. Even for the
functions where it does not automatically invoke undefined behaviour it
prevents the compiler from warning you if the parameters are incorrect
(such as not passing any to exit) so you should always include the
relevant header even if you can get away without it.
Also, if using gcc (which -Wall suggests to me you might be) you might
want to consider:
gcc -ansi -pedantic -Wall -O file.c
This will make gcc comply with the C89 (or possibly C95) standard and
generate additional helpful warnings.
--
Flash Gordon
Sometimes I think shooting would be far too good for some people.
Although my email address says spam, it is real and I read it.