[英]implicit declaration of function ‘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? 所以我一直在寻找关于
usleep()
东西,而我发现的所有东西都摆脱了#define
我已经做过了...有什么建议吗? 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);
You need to remove -std=c99
from your compiler command or use the _XOPEN_SOURCE
macro before including unistd.h
. 您需要从编译器命令中删除
-std=c99
,或在包含unistd.h
之前使用_XOPEN_SOURCE
宏。
If you want you can use -std=gnu99
instead of -std=c99
. 如果需要,可以使用
-std=gnu99
而不是-std=c99
。
nanosleep() worked for me: nanosleep()为我工作:
On a relevant note: usleep() has been removed since POSIX-2008 and recommends to use nanosleep() instead.
相关说明:自POSIX-2008以来已删除usleep()并建议使用nanosleep()代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.