包括 <string>在 Xcode 4.2 中找不到编译错误 [英] Include <string> not found compile error in Xcode 4.2

查看:26
本文介绍了包括 <string>在 Xcode 4.2 中找不到编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 XCode 中遇到 include not found 编译错误.我有一个 iOS 应用程序项目,我使用 Objective-c 和 c++ 作为混合.

I'm getting include not found compile error in XCode. I have an iOS app project that i use Objective-c and c++ as mix.

最初,我在我的 ios 项目中创建了一个 .h 文件和一个 .cpp 文件.然后,我将 .cpp 文件重命名为 .mm 文件.

Initially, i created one .h file and one .cpp file in my ios project. Then, I renamed the .cpp file to .mm file.

这是我的 .h 文件;

Here is my .h file;

TestLog.h

#ifndef CalculatorDemo_TestLog_h
#define CalculatorDemo_TestLog_h
#include <string>
using namespace std;

class TestLog
{
private:
    string logString;
public:
    void Log(string logMessage);
};


#endif

TestLog.mm

#include "TestLog.h"

void TestLog::Log(string logMessage)
{
    //this->logString->append(logMessage);

}

我错过了什么?我需要将 std c++ 库添加到我的 targetS 吗?与搜索标题路径相关的东西?

What am I missing? Do I need to add std c++ library to my targetS? Something related to Search Header Paths?

我只需要使用字符串类型.

I just need to use string type.

非常感谢您提前

推荐答案

选择项目 -> 构建设置 -> apple LLVM compiler 5.1 -> 语言

select project -> build setting -> apple LLVM compiler 5.1 -> language

Compile Sources As 中更改为 Objective-C++

这篇关于包括 &lt;string&gt;在 Xcode 4.2 中找不到编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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