Is there a library / framework that allows to program a Carbon application using C++ classes? [closed]
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
开发者_JS百科 Improve this questionIs there any library that allows to create a Carbon application using C++ classes?
There was once a C++ framework called PowerPlant, bundled with Metrowerks. It's now open sourced: Open PowerPlant. Ah, those were the days...
There was also something called MacApp, originally maintained by Apple itself. But it was abandoned during its transition to OS X. Some hardcore supporters seem to maintain a fork, apparently: ClubMacApp.
You can use Qt which is a respectable cross-platform C++ GUI library. It was built on top of Carbon, but it's now on top of Cocoa.
wxWidgets is also a cross platform C++ GUI library. Again it is in transition from Carbon-based to Cocoa-based.
Carbon itself, since OS X 10.2 Tiger, has an object system called HIToolbox, exposed by a C-interface, see Apple's guide, but it's written for people who knew the older, classic Toolbox. There's a C++ framework around it, included in Apple's sample codes, called HIFramework.
That said, it is strongly recommended to learn Objective-C and use Cocoa. The reasons are manifold:
Apple effectively stopped adding features to the GUI portion of Carbon framework. It's not available in 64 bit, etc.
If you already know C++ and thus have a working knowledge of pointers etc, it's very easy to learn Objective-C. It takes literally a day and that's it. For a comparison of Objective-C and C++, see this nicely summarized document by P. Chatelier. It is really, really good for those who know C++ already.
In any case the really hard part is getting used to the framework itself, be it Carbon or Cocoa, which is largely independent of the language. Unfortunately the resource on Carbon is very meagre on 'Net, and they are also rather dated. (The only things I know are CarbonDev and the venerable Macintosh C Carbon.) Apple made many nice additions to Carbon after they transitioned to OS X, but there is very few info on them except Apple's own terse documentation. Just compare the number of questions tagged
carbon
andcocoa
on SO. You have so much more available about Cocoa.
精彩评论