Re: Obj-c and c++ in same file
Re: Obj-c and c++ in same file
- Subject: Re: Obj-c and c++ in same file
- From: Andrew White <email@hidden>
- Date: Wed, 16 Mar 2005 08:57:26 +1100
Bob Clark wrote:
One "gotcha" is that if you mix (some) C++ stuff in your headers
(passing by reference, for example, if I recall correctly) then
Interface Builder will have trouble parsing the headers. So if you can
keep your headers closer to "pure" Objective-C you'll have an easier
time in Interface Builder. I've had to split up header files into
separate "Interface Builder-friendly" and "raw C++" headers to get
around this problem.
Related to this: if you have source files with different types then your
header files (which in the C family are merely raw text that is insert into
source files before compilation) must be compatible with the lowest common
denominator that will include them.
Example:
I have a project with 3 sorts of source files: .m, .mm and .cpp. The
header associated with the .cpp file uses C++ syntax. Any objective C file
(.m or .mm) that will include the C++ header, or include a file that
includes the C++ header, must be .mm, because the C/Objective-C compiler
can't handle the C++ extensions, while the Objective-C++ compiler handles
them fine. Conversely, the .cpp file includes only the C++ header, because
the C++ compiler will baulk at objective-C constructions.
Summary:
- You need to include the header (or make some reference to the code)
generate links to the code.
- Any header you include becomes part of the source file's code.
Therefore: you can mix C/C++/objective-C/objective-C++ languages in source
files. Just make sure you use the right compiler mode for the job.
--
--------------------------------------------------------------------------
This email and any attachments are confidential. They may contain legally
privileged information or copyright material. You should not read, copy,
use or disclose them without authorisation. If you are not an intended
recipient, please contact us at once by return email and then delete both
messages. We do not accept liability in connection with computer virus,
data corruption, delay, interruption, unauthorised access or unauthorised
amendment. This notice should not be removed.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden