c++ - 在 Objective C++ .mm 文件中包含 POCO 头文件会导致 Xcode 6 出现编译错误

标签 c++ xcode poco objective-c++ poco-libraries

如果我在 .mm 文件或 .h 文件中包含任何 POCO 头文件,我会看到以下奇怪的错误。如果我在 .cpp 文件中包含 header ,则项目会成功编译。任何使 POCO 与 Objective C 项目一起运行的帮助或示例代码都将不胜感激。

代码如下:

//File: test.mm

#import "test.h"    
#include "Poco/JSON/Object.h"

@implementation test
-(void)test{
 Poco::JSON::Object obj;
}
@end

这是错误 enter image description here 的截图 enter image description here

详细错误:

In file included from /Users/a/Desktop/test/theta/theta/test.mm:10:
In file included from /Users/a/Desktop/poco-1.6.0- all/JSON/include/Poco/JSON/Object.h:24:
In file included from /Users/a/Desktop/poco-1.6.0-all/JSON/include/Poco/JSON/Array.h:25:
In file included from /Users/a/Desktop/poco-1.6.0-all/Foundation/include/Poco/Dynamic/Var.h:26:
In file included from /Users/a/Desktop/poco-1.6.0-all/Foundation/include/Poco/Dynamic/VarHolder.h:24:
 In file included from /Users/a/Desktop/poco-1.6.0-all/Foundation/include/Poco/NumberFormatter.h:24:
/Users/a/Desktop/poco-1.6.0-all/Foundation/include/Poco/NumericString.h:261:8: error: expected member name or ';' after declaration specifiers
            void check(char* ptr)
            ~~~~ ^

最佳答案

好的,错误的原因是POCO头文件与OSX SDK中的头文件之一冲突。 在包含任何 header 之前添加以下行修复了编译问题。

#undef check

关于c++ - 在 Objective C++ .mm 文件中包含 POCO 头文件会导致 Xcode 6 出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30460636/

相关文章:

ios - 没有 USB 的 Xcode 6.1 调试?

c++ - 如何在 Eclipse IDE 中添加编译器选项

entity-framework - 将 ADO.net Entity Framework 4 与枚举一起使用?我该怎么做?

c++ - 无法让 windbg 识别我的扩展

c++ - 在 switch 语句中共享一个 case。表达问题。它是如何工作的?

c++ - 如何在 C++ 中划分元组

c++ - 如何最容易地用 c/c++ 处理 jpg 图像?

ios - 在自定义键盘上键入时播放自定义声音

ios - 带有 BigSur 的 Xcode 上的导航器和检查器行为

entity-framework - Entity Framework 从源代码管理中删除文件