Is there a library / framework that allows to prog

2019-08-28 11:33发布

Is there any library that allows to create a Carbon application using C++ classes?

1条回答
干净又极端
2楼-- · 2019-08-28 12:10

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:

  1. Apple effectively stopped adding features to the GUI portion of Carbon framework. It's not available in 64 bit, etc.

  2. 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.

  3. 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 and cocoa on SO. You have so much more available about Cocoa.

查看更多
登录 后发表回答