Why do i get this message from fedora 7's premade gcc 4.1.2 (but not from my other compiler, a homemade 3.3.6):
warning: incompatible implicit declaration of built-in function ‘exit’
Why do i get this message from fedora 7's premade gcc 4.1.2 (but not from my other compiler, a homemade 3.3.6):
warning: incompatible implicit declaration of built-in function ‘exit’
Maybe post some relevant code?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Code:int main () { exit(0); }
test.c: In function ‘main’:
test.c:2: warning: incompatible implicit declaration of built-in function ‘exit’
No more, no less...
exit() requires <stdlib.h> doesn't it? That's what "man 3 exit" says.
exit() requires <stdlib.h> doesn't it? That's what "man 3 exit" says.
Correct you are...I guess the fact that "exit()" still works without stdlib.h had me confused.
Thanks!
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
It "works" because you can still call any function without a prototype, the linker sorts that bit out. However, now the compiler is unable to tell whether the function is correctly used or not. It seems like 4.1.2 enables some more warnings by default, which gives you that warning. [Or perhaps exit() has been changed from a standard function to a builtin function - builtin functions are not normally extracted from a library, but instead, the compiler in itself knows how to produce the code for that function - many simple functions are builtin.]
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.