I am trying to use some C++ classes in my Objective-C code for an iPhone application. I am just trying to declare the C++ object, and I am running into problems. Even though I am declaring the C++ header file in the Objective-C class I want to use it in, it does not appear that my Objective-C recognizes the C++ object. Here is my Objective-C code:
//implementation file
#import "CPPClass.h"
@implementation MyViewController
- (void) viewDidLoad
{
CPPClass object;
}
but I get an "Use of undeclared identifier 'CPPClass'" warning.
How am I supposed to do this?
If you want to use C++ code in Objective-C you need to have it in files with the .mm extension, which the compiler will interpret as Objective-C++ code. You also should #include C++ headers, not #import them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With