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 the Cocoa 
functionality from my "pure" Cocoa files.

Thanks,
        Howard

On Jan 31, 2012, at 1:10 PM, Greg Parker wrote:

> 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 
>> errors, even though the .mm file itself compiles fine.
> 
> 
> What are the errors? What is in your .h file? I bet your .h file is including 
> Objective-C headers, which won't work when your .h file is included in a 
> plain .cpp file.
> 
> 
>> All the examples I find so far show making the call from a .mm file in the 
>> first place, but I can't do that because my code is also compiled for 32-bit 
>> Carbon (and Windows). 
> 
> What you tried above should work, once you figure out what is wrong with your 
> .h file.
> 
> An alternative:
> 1. Add Objective-C++ code to your existing .cpp file inside MAC_COCOA.
> 2. Tell Xcode that your .cpp file is actually Objective-C++.
> 
> 
> -- 
> Greg Parker     gpar...@apple.com     Runtime Wrangler
> 
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to