• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calling an Objective-C function from C++?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Calling an Objective-C function from C++? (From: Howard Moon <email@hidden>)

  • Prev by Date: Re: Calling an Objective-C function from C++?
  • Next by Date: Re: Calling an Objective-C function from C++?
  • Previous by thread: Re: Calling an Objective-C function from C++?
  • Next by thread: Re: Calling an Objective-C function from C++?
  • Index(es):
    • Date
    • Thread