ceil 可以在不包含的情况下工作在视觉c++ 2010年
我刚刚在 Visual Studio 2010 中编写了一个简单的 C++ 程序,并使用了 ceil 函数。但我忘记包含
,只包含
。令人惊讶的是我的代码编译成功并且运行没有任何错误。我读过一本 C++ 书籍,它清楚地表明要使用 ceil 函数,您必须包含
或
。为什么会出现这种情况?谁能给我解释一下吗?谢谢!
I just wrote a simple C++ program in Visual Studio 2010 and I use ceil
function. But I forgot to include the <cmath>
and only included the <iostream>
. Surprisingly my code compiled successfully and ran without any error. I read a C++ book and it clearly says that to use ceil
function you must include <cmath>
or <math.h>
. Why this happens? Can anyone explain me? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
从技术上讲,允许实现自动在系统标头中包含任何标头。但这是实现定义的。
在某些情况下,
已包含在内,在其他情况下则未包含 - 同样适用于所有其他标准标头。
这个问题出现在这个问题上:https:// stackoverflow.com/questions/7632926/is-this-ac-program-or-c-program-how-to-decide
除此之外,它可能会被其他包含间接包含。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
该标头是从其他(间接)包含的标头间接包含的。
要找出哪一个,请从项目选项中启用“保留预处理源”(
/P
) 并检查生成的 (*.i) 文件更新 刚刚发现 VS2010已重命名相关选项:
The header is indirectly included from some other (indirectly) included header.
To find out which one, enable 'keep preprocessed source' (
/P
) from the project options and inspect the resulting (*.i) fileUpdate Just found out that VS2010 has renamed the related option: