# How do I enable Objective-C++ use in Xcode 1.5?



## Aleran (Feb 10, 2005)

I want to mix C++ and Objective-C and heard Xcode supports this through Objective-C++. developer.apple.com has very little help on how I go about doing this. I found some example code they have, but when I just put it in a file with a .mm extension I still can't use the objects. It just seems to not like me mixing Objective-C and C++. How do I set my project to work in Objective-C++?

Thanks.


----------



## brianleahy (Feb 10, 2005)

I've never tried that, but it's supposedly do-able.

If you haven't already, check here:

http://developer.apple.com/document...eC/LanguageOverview/chapter_3_section_10.html


----------



## lurk (Feb 10, 2005)

Your description is not very clear.  What problems are you having and how can't you use the objects?  One thing to keep in mind is that you cannot inherit a C++ class from an Objective-C one and vise versa.


----------



## Aleran (Feb 10, 2005)

I have looked at that page. In fact I have that exact code they've written and the thing just wont compile when ever I try to import the HelloWorld.mm file. I get parse errors pretty much whenever I use the word "class" I got these same errors when I was trying to do this on my own (meaning before I tried using apples HelloWorld code as a start).

Does anyone have a very basic step by step process of creating a project that can run C++ and Objective-C? If you can give me that, it should be enough to get me started and on my way.


----------



## kainjow (Feb 10, 2005)

Here's a project I just created real fast for you. It's extremely simple. It has a  Controller class with an IBAction for a button. When the button gets clicked, it creates an instance of the Message C++ class and calls it's ShowMessage() method passing in a string (the method takes a parameter of type "string" - requires you to include iostream and string libraries. If you have any questions email me kainjow at kainjow dot com.

http://www.kainjow.com/code/CPlusPlusAndObjC.tar.gz


----------



## Aleran (Feb 10, 2005)

Thanks a lot! I'm downloading it now and will check it out.

EDIT: Yep it all ran and compiled fine. I'm not sure why mine wasn't working but from here I can experiment and figure out what went wrong. Thanks again.


----------

