c++ - 在 Xcode 4.2 中包含 <string> 未找到编译错误

标签 c++ objective-c xcode string header

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

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

这是我的 .h 文件;

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 吗?与搜索标题路径相关的东西?

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

非常感谢您提前

最佳答案

选择项目->build设置->苹果LLVM编译器5.1->语言

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

关于c++ - 在 Xcode 4.2 中包含 <string> 未找到编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10325853/

相关文章:

c++ - 让 OpenAL 在 C++ 中工作

objective-c - 拖放时可以从粘贴板获取完整路径吗?

objective-c - -fno-objc-arc 无法禁用 ARC

objective-c - 错误 : "Calls to mailbox_fql have exceeded the rate of 300 calls per 600 seconds"

xcode - 有没有办法将命令行选项从 Xcode 传递到我的 iOS 应用程序?

c++ - 为什么 std::is_convertible_v 返回 true 即使此转换不合法?

C++ - 设计问题

c++ - 模式识别和字符串匹配

ios - Xcode 4.4 错误

iphone - 如何删除最后一行并在 TableView 中添加更多行?