By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

question about implicit declaration error

P: n/a
Hi All,

I have the following:

#define MAX_SLEEP_TIME 1000
#include <unistd.h>

void do_sleep(){
unsigned int random;
while(TRUE){
srand(time(NULL)%getpid());
random = rand()%MAX_SLEEP_TIME;
if(random != 0) break;
}
usleep(random);
}

when I compile I get a warning that says "implicit declaration of usleep". I
thought usleep was declared in <unistd.h>

What have I got wrong and how can I fix it?

Thanks for your help

Michael

Aug 8 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 2007-08-08, michael <sp**@begone.netwrote:
Hi All,

I have the following:

#define MAX_SLEEP_TIME 1000
#include <unistd.h>

void do_sleep(){
unsigned int random;
while(TRUE){
srand(time(NULL)%getpid());
random = rand()%MAX_SLEEP_TIME;
if(random != 0) break;
}
usleep(random);
}

when I compile I get a warning that says "implicit declaration of usleep". I
thought usleep was declared in <unistd.h>

What have I got wrong and how can I fix it?
This would be better asked on comp.unix.progammer.

Check the man-page for the function. For example, under Linux, the
synopsis is:

#define _XOPEN_SOURCE 500 /* Or: #define _BSD_SOURCE */
#include <unistd.h>

int usleep(useconds_t usec);

Az.
Aug 8 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.