如果我在 .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
这是错误 的截图
详细错误:
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/