Thread: incompatible implicit declaration of built-in function ‘exit’

  1. #1
    Dragon Rider jas_atwal's Avatar
    Join Date
    Nov 2007
    Location
    India
    Posts
    54

    incompatible implicit declaration of built-in function ‘exit’

    C

    tried to compile a simple hello world program:
    Code:
    #include<stdio.h>
    
    int main()
    {
    	printf("Hello World\n"0;
    	exit(0);
    }
    when I compile the above code I get the following error:
    Code:
    $ gcc hello.c 
    hello.c: In function ‘main’:
    hello.c:6: warning: incompatible implicit declaration of built-in function ‘exit’
    Please tell me where am I going wrong?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    exit() is in <stdlib.h>, be sure to include it.

    BTW, you can just use return 0 from main(), no extra header files required.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Dragon Rider jas_atwal's Avatar
    Join Date
    Nov 2007
    Location
    India
    Posts
    54
    That helps! Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. Implicit declaration of function ...???
    By soothsayer in forum C Programming
    Replies: 8
    Last Post: 08-07-2006, 06:49 AM
  4. cannot start a parameter declaration
    By Dark Nemesis in forum C++ Programming
    Replies: 6
    Last Post: 09-23-2005, 02:09 PM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM