gcc 4.1.2

This is a discussion on gcc 4.1.2 within the Linux Programming forums, part of the Platform Specific Boards category; Why do i get this message from fedora 7's premade gcc 4.1.2 (but not from my other compiler, a homemade ...

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    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’

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    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...

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,651
    exit() requires <stdlib.h> doesn't it? That's what "man 3 exit" says.

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    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

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Run time differences in Linux gcc versions
    By circuitbreaker in forum C++ Programming
    Replies: 7
    Last Post: 02-14-2008, 10:09 PM
  3. Replies: 4
    Last Post: 09-02-2007, 08:47 PM
  4. Compiles on gcc 3.3 but not on gcc 4.0.3
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2007, 12:24 PM
  5. gcc
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-22-2003, 03:46 PM

Tags for this Thread


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