C, error of compilation during using “usleep” function

后端 未结 2 1860
余生分开走
余生分开走 2020-12-22 10:22

I use Ubuntu Linux. When I try use \"usleep\" function, I get information about \"implicit declaration of function usleep\". Below is the error code:

muteks.         


        
相关标签:
2条回答
  • 2020-12-22 10:29
    #include <unistd.h>
    

    See the man usleep

    0 讨论(0)
  • 2020-12-22 10:30

    usleep() is declared in the standard header unistd.h which you haven't included. Include it:

    #include <unistd.h>
    

    On a relevant note: usleep() has been removed since POSIX-2008 and recommends to use nanosleep() instead.

    0 讨论(0)
提交回复
热议问题