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++ ?



On the general topic of mixing Cocoa/Objective-C and C++, I might knock on wood and report a modest success story:

I have an application -- a Scheme-programming-language interpreter (Wraith Scheme) -- designed in the model/view/controller pattern. The model is essentially all straight C++ -- all ".c++" files and associated headers -- and when I use it in a standard Macintosh application, it runs in its own thread. The view and controller are in that case mostly Objective-C, with occasional references to things to get the model's thread going and keep in touch with it; they use all either ".m" or ".mm" files, with associated headers, and with lots of Cocoa calls.

I set the application up this way because I originally got the application going with the model running with two additional, different, view/controller combinations: The same C++ code for the model can run with a straight Unix-shell view/controller -- as a text- oriented line-at-a-time process in a "Terminal" window -- or with an "ncurses" view/controller, also running in a Terminal window. I followed that development path to port the program to Tiger from a much older Mac application, dating from pre-Carbon Mac-Toolbox days. I was a newcomer to Cocoa at the time of the port, so I did it that way in order to deal with upgrading the model separately from coming up to speed on Cocoa. I use #ifdefs on symbols defined by compile- time flags to control which build to create and to control how the model communicates with its view/controller -- the Cocoa version is built with XCode (2.4.1, on Tiger), the Unix versions with conventional make files. There are also, of course, different source files used for the different view/controller combinations.

This mix of languages, libraries, and build mechanisms has worked seamlessly so far (and this is where I knocked on wood). My suite of regression tests automatically builds and tests all of these versions, and there have been few maintenance problems associated with the differences between them. I suspect (another knock on wood) that it would be straightforward to adapt the Unix versions of the application to (heresy!) other Unix versions and other hardware platforms.

--  Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)

_______________________________________________

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>)
 >Re: programming in C++ ? (From: John Stiles <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.