Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

implicit declaration of function ‘usleep’

Tags:

c

warnings

usleep

So i've been looking stuff about usleep() and all I have found to get rid of this is #define which i have done... Any ohter suggestion? I need to get rid of this warning... Or any ideas on how to use sleep with miliseconds.

#define _BSB_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <time.h>

int r = rand() % 1000 +1;
usleep(r*1000);        
pthread_mutex_lock (&count_mutex);
like image 385
user3785202 Avatar asked Mar 31 '15 14:03

user3785202


1 Answers

You need to remove -std=c99 from your compiler command or use the _XOPEN_SOURCE macro before including unistd.h.

If you want you can use -std=gnu99 instead of -std=c99.

like image 112
Iharob Al Asimi Avatar answered Sep 28 '22 19:09

Iharob Al Asimi