Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set Carbon or Cocoa Project to use C++



sorry, u do not need to set *every* file in the project to compile as objective-c++, i know u can change your .cpp file to a .mm extension or change the file type in the info window. for it to work, the bottom line is to mix c++ with anything those particular files need to be compiled as objective-c++. it depends on your project, i was assuming your project would all want to use the same compiled language.
 
in the instances i have done this i wanted everything compiled as objective-c++ so it made more sense to chage the build setting just once then to change a setting on a file-by file basis for a bunch of .cpp files with cross platform code.
 
chris, are there any other negative consequences to this other than having files that appear to be compiled as something else because of their extension?? and i am asking that as a serious question, because if there are i would cert! ainly like to know ( ie, runtime issues, compiler optimizations?? ). i suppose this thread should not really be on the carbon list at this point, sorry.
 
it all depends on what your needs are i guess.
 
jamie 

Chris Hanson <email@hidden> wrote:
On Jan 20, 2006, at 11:13 AM, Jamie Gjerde wrote:

> there is a "compile source as" build setting.

You should generally use this as a last resort. Instead, your source
file suffixes should reflect the language used to compile that source
file. If you need to build a specific file as a specific language
without changing its name, you can also use the Info window for that
file within Xcode to set the language it should be treated as.

> the default is according to file extension but u can set it
> ot! herwise. like for cocoa, if u want to be able to include a c++
> class ( defined in a .cpp file ) in an objective c or an objective c
> ++ file u will need to have this set to Objective-C++ for that
> work. if xcode is set to compile according to file extension this
> would not work.

This is incorrect.

If you want to use a C++ class (by including a C++ header file) in a
Cocoa source file, that Cocoa source file needs to be compiled as
Objective-C++ rather than Objective-C. Thus your Cocoa source file
should have the ".mm" file extension.

You do not need to change the "Compile Source As" build setting in
order for this to work.

-- Chris




What are the most popular cars? Find out at Yahoo! Autos
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: Set Carbon or Cocoa Project to use C++ (From: Chris Hanson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.