Mix C++ with Objective-C

Discussion in 'Mac Programming' started by fernandovalente, May 9, 2009.

  1. fernandovalente macrumors 6502

    fernandovalente

    Joined:
    Aug 29, 2008
    Location:
    Third world **** hole, I mean, Brazil
    #1
    People always told me I can mix Objective-C, C and C++. I'm trying to write a program in Objective-C and C++. I tried to include iostream on my Objective-C code, but I got an error "File not found". How do I mix Objective-C with C++?
     
  2. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
  3. Sander macrumors 6502

    Joined:
    Apr 24, 2008
    #3
    Make sure to give your "Objective-C++" file the .mm extension, so the compiler knows it's not an ordinary Objective-C file and sets its include paths correspondingly.

    Note that there are limitations as to what features of C++ you can use and how you can use them. It's best to google for "Objective-C++" and read the primer on Apples website.
     

Share This Page