Re: Calling an Objective-C function from C++?
Re: Calling an Objective-C function from C++?
- Subject: Re: Calling an Objective-C function from C++?
- From: Fritz Anderson <email@hidden>
- Date: Tue, 31 Jan 2012 14:45:45 -0600
On 31 Jan 2012, at 1:31 PM, Howard Moon wrote:
> I'd like to add the ability to support Cocoa, by adding a .mm/.h file with the Cocoa code to display an NSAlert, and call it from here when the preprocessor symbol MAC_COCOA is defined. I've created the Cocoa files, but how can I include and call into that code from my .cpp file? Simply adding either #import or #include of my new .h file causes many many errors, even though the .mm file itself compiles fine.
I take it that the .h file has Objective-C directives and keywords? That'll never #include cleanly in C++.
Can you make a C++-compatible .h file that contains only the declarations of your bridging functions, set off with extern "C"{}? (The extern would itself have to be guarded by #ifdef __cplusplus.)
— F
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden