#include< string>在iOS中找不到C ++文件中的文件 [英] #include <string> file not found in iOS in C++ file

查看:641
本文介绍了#include< string>在iOS中找不到C ++文件中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS下有一个客观的c/c ++项目,将其从OS/X中移出,并且出现找不到文件"错误

I have a objective c/c++ project under iOS, moving it from OS/X and I get a 'file not found' error on

#include <string>

这是一个干净的项目,我刚刚添加了旧项目中的文件.是否在XCode中设置了STL?查找会产生多种可能性,例如

It's a clean project, and I've just added the files from the old project. Are the STL includes set up in XCode? A find produces a number of possibilities e.g.

/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/usr/include/c++/4.2.1/debug/

,但是将其添加到搜索路径中只会引发更多错误.有什么建议? (除了不使用字符串-它在我要移植的内部代码中)

but adding this to the search path just threw up more errors. Any suggestions? (apart from don't use string - it's in house code I'm porting)

xcode 4.2.1,在OS/X 10.7.3上运行的ios5.0,它位于.cpp文件中,该代码在OS/X上正常工作

xcode 4.2.1, ios5.0 running on OS/X 10.7.3 and it's in a .cpp file, the code works fine on OS/X

推荐答案

您真的确定<string>仅包含在.cpp文件中吗?

Are you really sure <string> is included only from a .cpp file?

我刚刚通过添加一个.cpp文件并包含<string>在一个新项目上进行了测试,并且它可以按预期工作(相同的Xcode版本,相同的SDK版本).

I just tested on a fresh project, by adding a .cpp file and including <string>, and it works, just as expected (same Xcode version, same SDK version).

但是,如果我在.m文件中包含<string>,那么我当然会遇到找不到文件"编译器错误.

But if I include <string> in a .m file, then of course I got a «file not found» compiler error.

因此请仔细检查,因为错误可能来自此处.

So double-check this, as the error may come from here.

您是要仅包含.cpp文件还是要包含供.cpp实现使用的.h文件中的<string>?
然后,它也可能包含在.m文件中,因此会出现错误.

Do you include <string> from a .cpp file only, or from a .h file, intended to be used by a .cpp implementation?
Then maybe it's also included by a .m file, hence the error.

还要检查您的预编译头(如果有),以查看是否在其中包含一些C ++内容...

Also check your precompiled headers, if any, to see if you include some C++ stuff there...

还请记住,在以后的情况下,可以在需要时依赖__cplusplus宏.

Also remember, in that later case, that you can rely on the __cplusplus macro, when needed.

这篇关于#include&lt; string&gt;在iOS中找不到C ++文件中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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