C++ xcode 4.5 中出现“iostream”文件未找到错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14376525/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'iostream' file not found error occur in xcode 4.5?
提问by Tirth
i m practising C++. i just add c++ files in XCode and write some string splitting functionality in it. After that i include that C++ file i.e. extension of .mm file in my AppDelegate file and call function from .h file of C++ class. But i found one static error in red line which is 'iostream' file not found. I used latest XCode version 4.5 and iOS 6.0. Please see screen shot of my error or xcode screen.
我在练习 C++。我只是在 XCode 中添加 C++ 文件并在其中编写一些字符串拆分功能。之后,我在我的 AppDelegate 文件中包含该 C++ 文件,即 .mm 文件的扩展名,并从 C++ 类的 .h 文件中调用函数。但是我在红线中发现了一个静态错误,即未找到“iostream”文件。我使用了最新的 XCode 4.5 版和 iOS 6.0。请查看我的错误或 xcode 屏幕的屏幕截图。
I m tried to modify my code as per given linkinformation but no success. :(
我试图根据给定的链接信息修改我的代码,但没有成功。:(
also i followed this linkinformation as well, but result is same.
我也跟着这个链接信息,但结果是一样的。
Thanks iHungry
谢谢 iHungry
采纳答案by arthankamal
Objective C
having .m
extensions for its implementation files. If you want to use C++
in Objective C
it should have .mm
extensions. you can include C++
header files in your .mm
file. But if you want to include your C++
header files in your .h
file, you need to check macro
for that, like
Objective C
具有.m
其实现文件的扩展名。如果你想使用C++
在Objective C
它应该有.mm
扩展。您可以C++
在文件中包含头.mm
文件。但是如果你想C++
在你的.h
文件中包含你的头文件,你需要检查macro
一下,比如
#ifdef __cplus
#include <iostream>
#endif
But, I haven't tried any functions by including C++
header file in .h
file. Hope it helps.
但是,我还没有通过C++
在.h
文件中包含头文件来尝试任何功能。希望能帮助到你。