I am currently working on a iOS development project. For convenience I split the features in several small programs in early stage. The project consists of Obj-C, Obj-C++ and C++ programs. Right now I am putting all them together into the final product and encountered some strange behaviors in terms of (I guess) compatibility between Obj-C and C++.
I am trying to initialize an object in an obj-C++ program, which comes from an obj-C class. But I keep getting error when compiling the obj-C class header file:
#import <Foundation/Foundation.h>
@class AVAssetExportSession;
@interface LibraryImport : NSObject {
AVAssetExportSession * export; //Error l开发者_运维知识库ine
NSError* movieFileErr;
}
//class methods
The transcript goes like this:
LibraryImport.h:24: error: expected unqualified-id before 'export'
LibraryImport.h:24: error: instance variable 'unnamed' has unknown size
LibraryImport.h:24: error: expected `;' before 'export'
The call goes like this in the obj-C++ file: (No error detected here, just feel something might related)
LibraryImport* import = [[LibraryImport alloc] init];
The weirdest part is that when it was originally called by a pure Obj-C program, it works really fine. But the project nature needs to change the caller to obj-C++. And also, when I tried to change the obj-C file to obj-C++, I got even more errors than before, including the existing one.
Here are the questions that keep me banging my head against the wall for the past whole week:
In this case, how I can successfully initialize this object?
Is this problem related to compatibility between obj-C and C++? If so, is there a general solution or some clear explanation on the compatibility?
Let me know if more information is needed (It's my first time encountering this problem and I don't even know where to start...). Any insight will be appreciated. Thank you very much :-)
Cheers,
Manca
I don't know Obj-C++, just C++.
Some compilers see export
as a keyword, try naming your variable differently.
精彩评论