The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Implicit Declaration Warning (C99 Linux)
Discuss Implicit Declaration Warning (C99 Linux) in the C Programming forum on Dev Shed. Implicit Declaration Warning (C99 Linux) C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 1st, 2013, 11:23 AM
|
 |
Contributing User
|
|
|
|
|
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");
|

February 1st, 2013, 11:49 AM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
|
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.
|

February 1st, 2013, 11:49 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Perhaps you might need to #define a macro. The man pages do mention this for waitid:
Quote:
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
|

February 1st, 2013, 12:51 PM
|
 |
Contributing User
|
|
|
|
Quote: | 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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|