#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    149
    Rep Power
    37

    Implicit Declaration Warning (C99 Linux)


    I'm using waitid and getting the following warning:
    Prog1.c:84: warning: implicit declaration of function ‘waitid’

    Here are my #includes:

    #include <sys/types.h>
    #include <sys/wait.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <time.h>
    #include <assert.h>

    I vaguely remember having a similar problem in the past, but I don't remember what I did about it and google isn't being terribly helpful today. The man page for waitid says to include sys/types and sys/wait so I'm not really sure what I'm missing.

    Code:
    				waitid(P_PID, pid1, 0, WEXITED);
    				printf("p1 exited\n");
    				waitid(P_PID, pid2, 0, WEXITED);
    				printf("p2 exited\n");
    				waitid(P_PID, pid3, 0, WEXITED);
    				printf("p3 exited\n");
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,175
    Rep Power
    2222
    Read those header files (or grep in their directory) to find waitid(). It might not be supported. I had certainly never heard of it (which doesn't mean anything), though I have heard of waitpid.

    Looking for it in those header files should solve your mystery.
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    Perhaps you might need to #define a macro. The man pages do mention this for waitid:
    Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

    waitid():
    Since glibc 2.12:
    _POSIX_C_SOURCE >= 200809L || _SVID_SOURCE ||
    _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
    Before glibc 2.12:
    _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
    _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
    Try adding -D_SVID_SOURCE in your gcc command line perhaps (or #define _SVID_SOURCE before your #include <sys/wait.h> line) and see if that solves it.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2009
    Posts
    149
    Rep Power
    37
    Originally Posted by Scorpions4ever
    Perhaps you might need to #define a macro. The man pages do mention this for waitid:

    Try adding -D_SVID_SOURCE in your gcc command line perhaps (or #define _SVID_SOURCE before your #include <sys/wait.h> line) and see if that solves it.
    Yep it was definitely something like that. I checked code I did for my systems programming course and saw a similar macro, so I defined it in my current project and the warning disappeared. Problem solved.

IMN logo majestic logo threadwatch logo seochat tools logo