confused about ObjC vs C++ file naming conventions
confused about ObjC vs C++ file naming conventions
- Subject: confused about ObjC vs C++ file naming conventions
- From: Jean-François Brouillet <email@hidden>
- Date: Sat, 17 Oct 2009 20:35:04 +0100
Hi.
Here's where I am, in a file called main.mm:
#import <UIKit/UIKit.h>
struct AutoPool {
NSAutoreleasePool * pool ;
AutoPool() { pool = [[NSAutoreleasePool alloc] init] ; }
~AutoPool() { [pool release] ; }
} ;
int main(int argc, char *argv[]) {
AutoPool pool ;
return UIApplicationMain(argc, argv, nil, nil) ;
}
Here's where I want to got to:
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
AutoPool pool ;
return UIApplicationMain(argc, argv, nil, nil) ;
}
That is, I want to put my C++ wrapper in the pch file, as in:
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ObjCCPPWrappers.h"
#endif
with ObjCCPPWrappers.h containing:
struct AutoPool {
NSAutoreleasePool * pool ;
AutoPool() { pool = [[NSAutoreleasePool alloc] init] ; }
~AutoPool() { [pool release] ; }
} ;
But all my attempts choke one way or another, the most
common one being:
/Users/verec/Projects/iPhone/ChorusT0/../common/ObjCCPPWrappers.h:6:0 /
Users/verec/Projects/iPhone/ChorusT0/../common/ObjCCPPWrappers.h:6:
error: expected specifier-qualifier-list before 'AutoPool'
Huh?
It is noteworthy that if I rewrite ObjCCPPWrappers.h as:
struct AutoPool {
// this is completely empty (and useless, obviously!)
} ;
then the compiler is happy ...
I tried to modify the attribute of ObjCCPPWrappers.h to
"sourcecode.cpp.objcpp"
or even do the same to the MyPrefix.pch ... to no avail.
Anyone know where I should dig to understand what I am supposed to do?
Many thanks.
--
JFB
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden