Professional Web Applications Themes

C++ in cocoa - Mac Programming

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...

  1. #1

    Default C++ in cocoa

    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
    Robert Guest

  2. #2

    Default Re: C++ in cocoa

    In article <1g9qedw.909w0a1tvt6rkN%de>,
    de (Robert W. Kuhn) wrote:
     

    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.
    Michael Guest

  3. #3

    Default Re: C++ in cocoa

    In article <mail-E513A5.23004825022004localhost>, Michael Ash
    <com> wrote:
     
    >
    > 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.[/ref]

    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!"
    James Guest

  4. #4

    Default Re: C++ in cocoa

    Michael Ash <com> wrote:
     
    >
    > 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.[/ref]

    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.
    Robert Guest

  5. #5

    Default Re: C++ in cocoa

    Robert W. Kuhn wrote: 

    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.
    Jhnny Guest

  6. #6

    Default Re: C++ in cocoa

    Jhnny Fvrt (it means "halo, then resonate") <com>
    wrote:
     
    >
    > 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,[/ref]

    My failure was the I changed the c++file.cpp to c++file.mm and not the
    mydoent.m to mydoent.mm

    Aaargh.

    Thanks to all! Now it works great!
    Robert Guest

  7. #7

    Default Re: C++ in cocoa

    In article <1g9r5d8.120zypq1kja7g8N%de>,
    de (Robert W. Kuhn) wrote:
     

    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
    Uli Guest

Similar Threads

  1. Considering Cocoa Books
    By David in forum Mac Programming
    Replies: 10
    Last Post: January 31st, 09:54 PM
  2. Cocoa + Xcode + GMP = What the?
    By M in forum Mac Programming
    Replies: 11
    Last Post: November 22nd, 11:46 PM
  3. Bit shifts in Cocoa
    By Korbin Meiser in forum Mac Programming
    Replies: 2
    Last Post: September 11th, 01:11 AM
  4. Q About Cocoa & CF Prefs..
    By David Phillip Oster in forum Mac Programming
    Replies: 2
    Last Post: July 31st, 12:04 PM
  5. [Cocoa] Bug with NSTableView?
    By Mark Bee in forum Mac Programming
    Replies: 1
    Last Post: July 7th, 07:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139