Thread: implicit declarations

  1. #1
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751

    implicit declarations

    I'm using DevC++ 4.0 on XP and somtimes when i call functions without the library i get an implicit declaration error and sometimes i don't. Are there any reasons for this anyone knows of?
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You should always #include the correct libraries.

    Sometimes including one library includes the desired one for you, which can give you the impression you've done it right, when you actually you haven't.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    If you call a function without a declaration in scope then you're asking for trouble. Be sure to include the header for the library and the question is moot.
    My best code is written with the delete key.

  4. #4
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    Try compiling this code
    Code:
    int main(void){
         printf("Hello World\n");
         return 0;
    }
    if you use gcc -o test test.c it will compile but if you use gcc -o test test.c -Wall -pedantic it won't. If your compiler is picky it'll ask you. If it isn't it won't work. You should always #inlcude the correct libraries

  5. #5
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    The compiler will assume the function being declared implicitly returns an int, it might have disastorous conquences for functions like malloc
    The one who says it cannot be done should never interrupt the one who is doing it.

  6. #6
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    I guess that answers that: just include the libraries and shut up.

    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Does gcc hate Forward declarations?
    By SevenThunders in forum C++ Programming
    Replies: 12
    Last Post: 03-16-2009, 02:03 PM
  2. Replies: 12
    Last Post: 10-24-2007, 08:10 AM
  3. implicit declaration of function?
    By BoneXXX in forum C Programming
    Replies: 2
    Last Post: 04-27-2007, 11:04 PM
  4. Implicit declaration of function
    By soothsayer in forum C Programming
    Replies: 5
    Last Post: 02-28-2006, 02:56 PM
  5. implicit declaration of malloc
    By cheezwhiz in forum C Programming
    Replies: 6
    Last Post: 01-13-2002, 01:17 PM