• 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: programming in C++ ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programming in C++ ?


  • Subject: Re: programming in C++ ?
  • From: Jiva DeVoe <email@hidden>
  • Date: Thu, 31 Jan 2008 08:17:51 -0700

Like you I used to be a primarily c++ coder,and using objective-c++ enabled an easier transition for me to obj-c.

It does give you some nice features like the ability to declare variables anywhere in your code, not just at the top, and the ability to fall back on STL classes when needed.

That said, however, I just finished converting all that code over to straight obj-c for a lot of the reasons already given. Also, some of the newer Xcode features like refactoring etc dont work with obj-c++, so if you want to get the most out of Xcode, you may want to use obj-c.

Some things to make your life easier if you do:

- enable C99 which enables declaring variables anywhere etc
- you can mix .m .mm and .cc files to your hearts content even in the same project with no effort at all. Use this to interface with whatever libs you need.


--
Jiva DeVoe
http://www.random-ideas.net

On Jan 31, 2008, at 1:22 AM, Thomas Engelmeier <email@hidden > wrote:


On 31.01.2008, at 00:17, Cor wrote:

For QTKit I seem te need to write in Objective-C.
For the IOKit I need to write in C++.

I'm a experienced C++ programmer, so I prefer to program in C++, but how do I interface to QTKit?

I did read something about .mm files.
If I understand correctly then .mm files may contain Object-C and C+ + mix.
But if this is so, why are not all files .mm (why are .m files needed?).

[...]

Does it hurt when I only use .mm files?

Yes. Significantly higher compile times and as others stated, different parsing, in this case: stronger type checking.
While the Obj-C compiler does not complain in a number of places where you assign the 'id' you get back from [anArray objectAtIndex:i] to e.g. an NSString *, the C++ compiler does.
So basically, to silence the compiler, quite some casts are required, which is IMHO fundamentally against the spirit of C++.
OTOH, for many Cocoa runtime errors you get at least a compiler warning, so you probably don't want noise on your compiler warnings.


Another sidenote: IOKit uses AFAIK an exception- and template-less subset of C++, so the mix with Objective-C is far smoother.
(IMO, the maior PITA for CORRECT code are the different exception handling mechanisms).


Does it makes sense to write Cocoa applications in C++?

No. But it makes partially sense to write it in Objective-C++ ;-).

Regards,
   Tom_E
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: programming in C++ ?
      • From: "Shawn Erickson" <email@hidden>
References: 
 >programming in C++ ? (From: "Cor" <email@hidden>)
 >Re: programming in C++ ? (From: Thomas Engelmeier <email@hidden>)

  • Prev by Date: Re: killing background processes with UNIX in cocoa?
  • Next by Date: Re: NSPopUpButtonCell always select first item
  • Previous by thread: Re: programming in C++ ?
  • Next by thread: Re: programming in C++ ?
  • Index(es):
    • Date
    • Thread