 |
|
 |
|
Next: How create aliases?
|
| Author |
Message |
External

Since: Mar 31, 2004 Posts: 45
|
(Msg. 1) Posted: Wed Feb 25, 2004 3:31 pm
Post subject: C++ in cocoa Archived from groups: comp>sys>mac>programmer>help (more info?)
|
|
|
Hello,
I read various statements in google but...
Is it now possible to use c++ in "traditional" obj-c cocoa applications?
Tschau - Robert
--
vertrau
voraus voraus |
|
| Back to top |
|
 |  |
External

Since: Jun 23, 2003 Posts: 321
|
(Msg. 2) Posted: Wed Feb 25, 2004 5:00 pm
Post subject: Re: C++ in cocoa [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <1g9qedw.909w0a1tvt6rkN%robert@vermtech.de>,
robert.TakeThisOut@vermtech.de (Robert W. Kuhn) wrote:
> Hello,
>
> I read various statements in google but...
>
> Is it now possible to use c++ in "traditional" obj-c cocoa applications?
Renaming your files to have a .mm extension will enable the
Objective-C++ compiler, which allows you to mix ObjC and C++ in the same
file. There are some gotchas, mostly relating to templates and C++ not
really grasping ObjC's weak type system, but for the most part it just
works. Apple has docs on it in the Release Notes section if you want
more info. |
|
| Back to top |
|
 |  |
External

Since: Feb 12, 2004 Posts: 66
|
(Msg. 3) Posted: Wed Feb 25, 2004 5:00 pm
Post subject: Re: C++ in cocoa [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <mail-E513A5.23004825022004@localhost>, Michael Ash
<mail RemoveThis @mikeash.com> wrote:
> In article <1g9qedw.909w0a1tvt6rkN%robert@vermtech.de>,
> robert RemoveThis @vermtech.de (Robert W. Kuhn) wrote:
>
> > Hello,
> >
> > I read various statements in google but...
> >
> > Is it now possible to use c++ in "traditional" obj-c cocoa applications?
>
> Renaming your files to have a .mm extension will enable the
> Objective-C++ compiler, which allows you to mix ObjC and C++ in the same
> file. There are some gotchas, mostly relating to templates and C++ not
> really grasping ObjC's weak type system, but for the most part it just
> works. Apple has docs on it in the Release Notes section if you want
> more info.
Big point to remember: Objective C objects are not C++ objects and you
need to remember which any particular object is as it will determine
the syntax of how you will call it's methods/members.
Spence
--
James P. Spencer
Rochester, MN
"Badges?? We don't need no stinkin badges!" |
|
| Back to top |
|
 |  |
External

Since: Mar 31, 2004 Posts: 45
|
(Msg. 4) Posted: Thu Feb 26, 2004 1:19 am
Post subject: Re: C++ in cocoa [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Michael Ash <mail.RemoveThis@mikeash.com> wrote:
> > I read various statements in google but...
> >
> > Is it now possible to use c++ in "traditional" obj-c cocoa applications?
>
> Renaming your files to have a .mm extension will enable the
> Objective-C++ compiler, which allows you to mix ObjC and C++ in the same
> file.
Must be in the same file? Is it possible the include (or import) the
header file (*.h) in the obj-c file where I use the c++-class?
I added the cppfile.mm and the cppheader.h to the project and did a
#include "cppheader.h" or a
#import "cppheader.h" or a
but get errors just in the line of the declaration of the c++-object.
Thank you and bye. |
|
| Back to top |
|
 |  |
|
it_means_"halo,_then_reso
|
External

Since: Mar 05, 2004 Posts: 162
|
(Msg. 5) Posted: Thu Feb 26, 2004 1:19 am
Post subject: Re: C++ in cocoa [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Robert W. Kuhn wrote:
> Must be in the same file? Is it possible the include (or import) the
> header file (*.h) in the obj-c file where I use the c++-class?
>
> I added the cppfile.mm and the cppheader.h to the project and did a
> #include "cppheader.h" or a
> #import "cppheader.h" or a
> but get errors just in the line of the declaration of the c++-object.
if you're going to include a c++ header in an obj-c source file, then
that file must be compiled in obj-c++ mode. as previously mentioned,
the easiest way to do that is to change the extension from .m to .mm,
but you can also do it via compiler switches. |
|
| Back to top |
|
 |  |
External

Since: Mar 31, 2004 Posts: 45
|
(Msg. 6) Posted: Thu Feb 26, 2004 10:37 am
Post subject: Re: C++ in cocoa [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Jøhnny Fävòrítê (it means "halo, then resonate") <this.is.RemoveThis@fake.com>
wrote:
> > Must be in the same file? Is it possible the include (or import) the
> > header file (*.h) in the obj-c file where I use the c++-class?
> >
> > I added the cppfile.mm and the cppheader.h to the project and did a
> > #include "cppheader.h" or a #import "cppheader.h" or a but get errors
> > just in the line of the declaration of the c++-object.
>
> if you're going to include a c++ header in an obj-c source file, then
> that file must be compiled in obj-c++ mode. as previously mentioned,
> the easiest way to do that is to change the extension from .m to .mm,
My failure was the I changed the c++file.cpp to c++file.mm and not the
mydocument.m to mydocument.mm
Aaargh.
Thanks to all! Now it works great! |
|
| Back to top |
|
 |  |
External

Since: Jun 22, 2005 Posts: 268
|
(Msg. 7) Posted: Thu Feb 26, 2004 2:19 pm
Post subject: Re: C++ in cocoa [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <1g9r5d8.120zypq1kja7g8N%robert@vermtech.de>,
robert DeleteThis @vermtech.de (Robert W. Kuhn) wrote:
> Must be in the same file? Is it possible the include (or import) the
> header file (*.h) in the obj-c file where I use the c++-class?
Yes, that should just work, as long as any source file that contains or
#includes/#imports both ObjC and C++ code is a .mm file (assuming you
don't use one of the other means to tell the compiler to use the ObjC++
compiler on that file).
Cheers,
-- Uli
http://www.zathras.de |
|
| Back to top |
|
 |  |
| Related Topics: | [Cocoa] Bug with NSTableView? - Hello all, I have a small yet significant problem, and I can't figure out for the life of me, why it's happening. I...
Icons in cocoa menus?? - Hey all-- I poked around the developer docs and on Apple's web site, but it looks as though NSMenu doesn't natively s...
Q About Cocoa & CF Prefs.. - It is my understanding that when you use the core foundation calls to write to an application's preferences, those pre...
java, MacOSX, and Cocoa - I just bought my first Mac, and I have been using it for server side java development. This is working just fine. I ...
[COCOA] Dynamic button? - Hi, Can someone please tell me how to make a dynamic button? It has to change its title and target by holding down th...
Can control-zero be handled in Cocoa? - I'm writting a Cocoa app where I want to be able to use control-zero to set the text field currently being edited to NU... |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|