undefined reference to "sleep"

来源:互联网 发布:linux piwik安装详解 编辑:程序博客网 时间:2024/05/11 11:37

From: http://hi.baidu.com/amwdi/item/bf2d61075b25a1dd73e6760b

undefined reference to "sleep"

#include <stdio.h>
#include <unistd.h>
int main()
{
    printf("Test starts.\n");
    sleep(1);
    printf("Test ends.\n");

    return 1;
}
    

Try this at the top:

#ifdef __unix__
# include <unistd.h>
#elif defined _WIN32
# include <windows.h>
#define sleep(x) Sleep(1000 * x)
#endif


原创粉丝点击