Implicit function declaration 'usleep

So, I was looking for stuff about usleep(), and all I found to get rid of it #definewas that I did ... Any suggestion ohter? 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);
+4
source share
1 answer

You need to remove it -std=c99from the compiler command or use a macro _XOPEN_SOURCEbefore turning it on unistd.h.

If you want, you can use -std=gnu99instead -std=c99.

+4
source

All Articles