Re: I need clarification on limitations of integrating C++ with Obj C
Re: I need clarification on limitations of integrating C++ with Obj C
- Subject: Re: I need clarification on limitations of integrating C++ with Obj C
- From: Rush Manbert <email@hidden>
- Date: Tue, 21 Mar 2006 12:47:59 -0800
Shawn Erickson wrote:
On 3/21/06, Rush Manbert <email@hidden> wrote:
The only thing I have done to make this work, is to tell the project to
"Compile Sources As" Objective C++. Maybe you need to do this so that it
will search for standard library headers? (I don't know how this relates
to your source file types. I don't mess with those.)
Changing "Compile Sources As" really shouldn't be needed (it most
common situations). If a file contains Objective-C make it end in
".m". If a file contains C++ make it end in ".cpp". If a file contains
C++ and Objective-C make it end in ".mm". Also if you have aspects of
".h" files that only should be compiled for C++ or Objective-C, etc.
you can wrap them which the appropriate #ifdefs so they are only seen
by the correct compiler (#ifdef __cplusplus, #ifdef __OBJC__, etc.).
It does turn out to be required in this situation because we end up with
file.m being compiled and somewhere in its include chain someone
includes <string>, but file.m is being compiled as Objective-C, and the
compiler can't find the standard lib header.
I changed my library adapter file (the mixed Obj-C/C++ one) to have the
mm extension, and I cleared the override on "Compile Sources As". My
build failed with this error:
In file included from
../../../../../capo/libraries/inc/libtest/adapterMac/libtestAdapter.h:12,
from
/Users/rmanbert/development/iml/capo/tools/capoBrowserMultiWin/mac/capoBrowser/BrowseWindowController.h:12,
from
/Users/rmanbert/development/iml/capo/tools/capoBrowserMultiWin/mac/capoBrowser/SourceViewController.m:10:
../../../../../capo/libraries/inc/libtest/libtestApi.h:12:22: error:
functional: No such file or directory
../../../../../capo/libraries/inc/libtest/libtestApi.h:13:18: error:
string: No such file or directory
../../../../../capo/libraries/inc/libtest/libtestApi.h:14:18: error:
vector: No such file or directory
The file being compiled is pure Objective-C as far as it knows, but the
include chain brings in the std lib headers, which causes the failure.
I overrode the "Compile Sources As" to say Objective-C++ and the build
succeeds.
From the symptoms that I saw after making the change, and the original
post, it seems to me that John needs to try overriding the "Compile
Sources As" to say Objective-C++.
- Rush
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden