Re: Problem with Objective-C++ Header Files

David Dunham <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
On 8 Jan 2010, at 08:23, Stephen Furlani wrote:

> I have an extensive library of C++ code that I want to be able to
> incorporate into my Objective-C project.  Following the tutorials provided
> by Apple and others, I've renamed my object file to .mm to utilize
> Objective-C++.
> 
> If I include the header files from my C++ library, I get a swath of errors,
> namely surrounding the use of 'id' in the subsequent included C++ header
> files.  I also get some more serious errors in the incompatibility between
> X.h (from XFree86) and objc.h over the use of 'BOOL' and 'cursors'.

I've got a fair amount of Objective-C++ code and haven't run into this, so I think you may need to give a more specific example.

(I usually run into the opposite problem, I've got a C++ file inadvertently included in an Objective-C source, and I have to rename it from .m to .mm.)

> Renaming the object file back to .cpp, the project compiles without error,
> so I know it's because of the inclusion of the Objective-C keywords.
> 
> How can I tell XCode to include those headers strictly as C++ headers and
> not Objective-C headers?  I thought using #include instead of #import would
> be clear enough.


That's a reasonable guideline, but #import is effectively just a free #pragma once.

David Dunham     Creator of Jigami, a unique game 
for iPhone/iPod touch  http://a-sharp.com/jigami/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.