C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-14-2008, 10:45 AM   #1
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
gcc 4.1.2

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’
MK27 is offline   Reply With Quote
Old 07-14-2008, 11:05 AM   #2
and the hat of vanishing
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 21,214
Maybe post some relevant code?
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Up to 8Mb PlusNet broadband from only £5.99 a month!
Salem is offline   Reply With Quote
Old 07-14-2008, 11:28 AM   #3
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
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...
MK27 is offline   Reply With Quote
Old 07-14-2008, 11:36 AM   #4
and the Hat of Ass
 
Join Date: Dec 2007
Posts: 731
exit() requires <stdlib.h> doesn't it? That's what "man 3 exit" says.
rags_to_riches is offline   Reply With Quote
Old 07-14-2008, 11:39 AM   #5
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
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!
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is offline   Reply With Quote
Old 07-14-2008, 01:22 PM   #6
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Quote:
Originally Posted by MK27 View Post
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!
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.
matsp is offline   Reply With Quote
Reply

Tags
compiler

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Profiler Valgrind afflictedd2 C++ Programming 4 07-18-2008 09:38 AM
Run time differences in Linux gcc versions circuitbreaker C++ Programming 7 02-14-2008 11:09 PM
How does compiler/linker such as GCC decide to start locating the appropriate library shong9 C Programming 4 09-02-2007 08:47 PM
Compiles on gcc 3.3 but not on gcc 4.0.3 cunnus88 C++ Programming 5 03-29-2007 12:24 PM
gcc DavidP A Brief History of Cprogramming.com 21 10-22-2003 03:46 PM


All times are GMT -6. The time now is 12:20 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22