函数“sleep()"的正确#include 是什么? [英] What is the proper #include for the function 'sleep()'?

查看:74
本文介绍了函数“sleep()"的正确#include 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Big Nerd Ranch 的书籍 Objective-C Programming,它首先让我们在前几章中用 C 编写.在我创建的其中一个程序中,我使用了睡眠功能.在书中,它告诉我将 #include 放在 #include 部分下.这应该消除C99 中函数‘睡眠’的隐式声明无效"的警告.但是出于某种原因,在我放入 #include <stdlib.h> 后,警告并没有消失.. 这个问题并没有阻止程序正常运行,但我只是好奇哪个 #include 我需要使用!

解决方案

睡眠 手册页 表示它在 中声明.

简介:

#include 

<块引用>

unsigned int sleep(unsigned int seconds);

I am using the Big Nerd Ranch book Objective-C Programming, and it starts out by having us write in C in the first few chapters. In one of my programs it has me create, I use the sleep function. In the book it told me to put #include <stdlib.h> under the #include <stdio.h> part. This is supposed to get rid of the warning that says "Implicit declaration of function 'sleep' is invalid in C99". But for some reason after I put #include <stdlib.h>, the warning does not go away.. This problem does not stop the program from running fine, but I was just curious on which #include I needed to use!

解决方案

The sleep man page says it is declared in <unistd.h>.

Synopsis:

#include <unistd.h>

unsigned int sleep(unsigned int seconds);

这篇关于函数“sleep()"的正确#include 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆