• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [SOLVED] C++ in a Cocoa App - How Hard is THAT?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SOLVED] C++ in a Cocoa App - How Hard is THAT?


  • Subject: Re: [SOLVED] C++ in a Cocoa App - How Hard is THAT?
  • From: Chris Hanson <email@hidden>
  • Date: Sun, 9 Oct 2005 01:23:39 -0700

On Oct 8, 2005, at 10:20 AM, Lance Drake wrote:

Compiling the C++ file occurs entirely without incident - it was including the C++ header file with 'class myObject {... }' in the Objective-C header that caused all the commotion.

Yes, that will cause some issues. Generally you should use a minimum set of include directives — no matter whether you're using Objective- C, Objective-C++, or C++ — to help avoid some issues.


In other words, unless you actually need the full class declaration for myObject above, don't include its header. Instead, just use a forward declaration.

In the project 'style' settings I set "Compile Sources As" to be 'Objective-C++'. That was it. I KNEW it had to be something simple - hence the query, "How hard is THAT?".

That's one solution, however, that means every C-derived source file in your project -- whether it's a C, C++, Objective-C, or Objective-C+ + file -- is compiled as Objective-C++. This may or may not be what you want.


Often you may want to minimize the header/declaration overlap as I describe above so you don't have to build your entire project as Objective-C++.

  -- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [SOLVED] C++ in a Cocoa App - How Hard is THAT?
      • From: Daniel Jalkut <email@hidden>
References: 
 >[SOLVED] C++ in a Cocoa App - How Hard is THAT? (From: Lance Drake <email@hidden>)

  • Prev by Date: Re: GDB: Does "catch vfork" work?
  • Next by Date: Can I create a Cocoa palette based on Carbon?
  • Previous by thread: [SOLVED] C++ in a Cocoa App - How Hard is THAT?
  • Next by thread: Re: [SOLVED] C++ in a Cocoa App - How Hard is THAT?
  • Index(es):
    • Date
    • Thread