Is there a way to include an objective-c header from a cpp? Because when I try to #include “cocos2d.h” from a cpp .h file, a lot of errors complaining about @’s and -‘s are showing up.
Can c++ files include obj-c headers like that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is possible, but you need to use Objective-C++ (e.g. by making the file extension
.mm) to mix the languages, plain C++ sources don’t work.To make that clear:
.mfiles only allow Objective-C sources.cppfiles only allow C++ sources.mmallow mixed Objective-C++ sources – i.e. both Objective-C and C++ with some limitationsIf you need to keep the two worlds seperated instead you need to write wrapper classes that hides the Objective-C details from C++ and vice versa.