On Sun, Feb 8, 2009 at 8:42 PM, Peter N Lewis <pe...@stairways.com.au> wrote:
> At 12:29 -0800 7/2/09, Steve Wart wrote:
>
>> It works fine in 10.5.6 with XCode 3.1 if I change the file type of
>> BasicOpenGLView.m to sourcecode.cpp.objcpp.
>
> You normally use the extension .mm for Objective C++ code.
>
> At 10:41 +0900 9/2/09, Peter N Lewis wrote:
>>
>> At 13:12 -0800 7/2/09, Steve Wart wrote:
>>>
>>> Solved, thanks to the archives.
>>>
>>> #ifdef __cplusplus
>>> extern "C" {
>>> #endif
>
> Personally, I just switch the whole project to compile everything in
> Objective C++ and this eliminates the need for ifdef __cplusplus at
> essentially no cost in compile time, execution speed or executable size.  It
> just means you are only dealing with one version of C to go with your
> Objective C rather than C, C++ and Objective C.

Just beware that you might end up having to redo some of your code.
C++ is not a strict superset of C, alas, and there are many common C
coding styles which simply won't compile as C++.

I don't think there are any behavior changes, where the same code
would be legal C and C++ but not actually do the same thing, but it
wouldn't surprise me.

If you tend to work in C++ everywhere anyway then building your whole
project as C++ can make a lot of sense. If you do C++ in one small
corner of the application it's often not such a good idea. As always,
it will depend on what you're doing.

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to