Calling an Objective-C function from C++?

2012-01-31 Thread Howard Moon
Hi all, How does one call a Cocoa function from C++ code? I've got an existing .cpp file that leverages the vstgui framework, which includes support for Cocoa in the underlying layers. However, vstgui does not support dialogs or alerts. My code already supports native Windows

Re: Calling an Objective-C function from C++?

2012-01-31 Thread David Duncan
On Jan 31, 2012, at 11:31 AM, 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

Re: Calling an Objective-C function from C++?

2012-01-31 Thread Fritz Anderson
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

Re: Calling an Objective-C function from C++?

2012-01-31 Thread Charles Srstka
On Jan 31, 2012, at 1:31 PM, Howard Moon wrote: How does one call a Cocoa function from C++ code? I've got an existing .cpp file that leverages the vstgui framework, which includes support for Cocoa in the underlying layers. However, vstgui does not support dialogs or alerts.

Re: Calling an Objective-C function from C++?

2012-01-31 Thread Greg Parker
On Jan 31, 2012, at 11:31 AM, Howard Moon how...@antarestech.com wrote: How do I call from a .cpp file into a .mm file? Write a C or C++ function in the .mm file that is called by the .cpp file. Nothing magic. Simply adding either #import or #include of my new .h file causes many many

Re: Calling an Objective-C function from C++?

2012-01-31 Thread Howard Moon
Thanks, guys, you pointed out my problem. I had my Cocoa-specific functions in the same header file I was including from my pure C++ file. Instead, I now have an intermediate .h and .mm file that don't expose any Cocoa stuff to my original file, and the intermediate .mm file imports and uses

Re: Calling an Objective-C function from C++?

2012-01-31 Thread Dave Zarzycki
Howard, If you don't want to rename your .cpp file to .mm, then you can just tell Xcode to ignore the file extension and always compile as Objective-C++. Then your C++ code can call Objective-C code natively when compiling for Mac OS X / iOS. davez On Jan 31, 2012, at 11:31 AM, Howard Moon