Thread: Implicit declaration of function

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    13

    Implicit declaration of function

    Hi,
    i've done some search in this forum but didn't find any solution.
    Basically, my program use some functions like: strcpy, strlen ...

    When compiling, it throws some warnings:

    server.c:114: warning: implicit declaration of function `strstr'
    server.c:117: warning: implicit declaration of function `strncpy'
    server.c:125: warning: implicit declaration of function `strlen'
    ....
    .....

    How do i get rid of it (not by using tag while compiling) ? Do i need to #define or #include any extra thing ?

  2. #2
    ex-DECcie
    Join Date
    Dec 2005
    Posts
    125
    Sounds like you need to include string.h

    Code:
    #include <string.h>
    Mr. Blonde: You ever listen to K-Billy's "Super Sounds of the Seventies" weekend? It's my personal favorite.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    13
    i did include both <string.h> and <strings.h>
    But still no help !

    Anh

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Post your code and what compiler you're using.
    Sent from my iPadŽ

  5. #5
    Registered User
    Join Date
    Jan 2006
    Posts
    13
    Here's the begining of the source code (all include and define):

    Code:
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <netdb.h> 
    #include <ctype.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <strings.h>
    
    #define BUFFERLENGTH 256
    #define _GNU_SOURCE


    And im using
    Code:
     cc -Wall -o
    to compile and generate binary

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    server.c:114: warning: implicit declaration of function `strstr'
    server.c:117: warning: implicit declaration of function `strncpy'
    server.c:125: warning: implicit declaration of function `strlen'
    Those functions are all in <string.h>. They are ANSI functions and shouldn't be affected by #defines or compiler switches.

    Try a simple program that uses strlen(), with and without <string.h> included.

    If that doesn't work, maybe you should post more of your code.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Replies: 15
    Last Post: 11-11-2007, 10:40 AM
  3. Implicit declaration of function : wait()
    By husust in forum C Programming
    Replies: 2
    Last Post: 02-06-2006, 09:35 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. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM