Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programming in C++ ?



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >programming in C++ ? (From: "Cor" <email@hidden>)
 >Re: programming in C++ ? (From: Thomas Engelmeier <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.