error: ‘usleep’ was not declared in this scope
错误的脚本中添加头文件: #include <unistd.h>
【问题】error:在Linux系统下Sleep()函数未声明(was not declared)
首先,sleep()函数的使用要先包含头文件,Windows下使用#include <windows.h>,gcc编译器中(即可用于Linux系统)使用#include <unistd.h>
注意:在Windows中Sleep()单位为毫秒,sleep()单位为秒(如果需要更精确可以用usleep单位为微秒);在Linux中sleep中的“s”不大写,sleep()单位为秒,usleep()里面的单位是微秒。
所以在Linux系统下使用该函数,S不能大写
参考资料:
https://blog.csdn.net/qq_21950671/article/details/91450221
https://blog.csdn.net/SmaICG/article/details/88893842?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
网友评论