Unknown type name 'class'; did you mean 'Class'? 问题的解决
Xcode中可以混编C++和Objective-C,但是今天遇到了一个很令人抓狂的问题
在oc的.h文件里包含c++的.h文件时,总是报这个错:
Unknown type name 'class'; did you mean 'Class'?
意思是说不认识class这个类型,可是这是c++的定义啊。
去stackoverflow.com查了一下也没有找到好的答案,折腾了好久好久。
终于搞明白了,原来在把.m改成.mm之后,
在.mm文件里包含c++的头文件就可以了,不能在objective-c的.h文件里面包含c++。
弄完之后发现,
clang: error: invalid deployment target for -stdlib=libc++ (requires iOS 5.0 or later)
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
又一个蛋疼的问题,如何结局呢,通过
stackflow找到一个解决方案,但是尝试之前,我需要学习下snapshot的使用,因为我没有做版本控制,好吧,确实很危险,但是特殊情况。http://derkin2jessie.blog.51cto.com/1009410/1194882
stackflow上找到的方案是
Creating Projects Projects created using this Xcode release use the new libc++ implementation of the standard C++ library. The libc++ library is available only on iOS 5.0 and later and OS X 10.7 and later. 12221787 To enable deployment on earlier releases of iOS and OS X in your project, set the C++ Standard Library build setting to libstdc++ (Gnu C++ standard library). 为了实现这个方案,不得已的,更改调用cpp静态文件中类的自定义类中一些函数的使用 很痛苦有木有 最终编译通过,不过还没有真机测试,待续。。。
转载于:https://blog.51cto.com/derkin2jessie/1194855