HICococaView 未使用 GCC 4.2 进行编译

发布于 2024-10-13 08:00:09 字数 2743 浏览 5 评论 0原文

我们有一个大型的基于 Carbon(PowerPlant)的应用程序,我们最终希望将其移植到 Cocoa 上。我们将逐步进行此操作,第一步是尝试在 Carbon 窗口中获取 Cocoa 视图。

问题似乎是,当我使用 HICOcoaView.h 中的任何函数时,除非我将编译器从 GCC 4.2 切换到 GCC 4.0,否则应用程序将无法编译。

使用 GCC 4.0 以外的任何编译器时,我在 XCode 中收到错误,指出函数不可用,例如“HICocoaViewCreate 不可用”。

我不明白为什么这不起作用,我们是否必须切换到较旧的编译器,或者是否可以更改一些设置以使其编译?

非常感谢任何有关将 Carbon 移植到 Cocoa 的帮助或有用文档的指示。我已经阅读了旧的 Carbon Cocoa Integration 指南,但它没有提到这一点。

编辑:根据要求,这里是 gcc 命令行构建的输出:-

/Developer/usr/bin/gcc-4.2 -x Objective-c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wmissing-prototypes -Wreturn-type -Wunused-variable -Wunused-value -D__IMPRO_DEBUG_BUILD__ -isysroot /Developer/SDKs/MacOSX10.5 .sdk-m修复并继续 -mmacosx-version-min=10.5 -gdwarf-2“-I/Users/matt/Code/MattsFeatureBranch/Modules/User Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module Bundle.build/User Notes.hmap" -W括号 -Wno-conversion -Wno-sign-compare -Wno-multichar -Wno-deprecated-declarations "-F/Users/matt/Code/MattsFeatureBranch/Modules/User Notes/Mac/../../../Build Products/Mac/Debug/Plugins" "-F../../../Build 产品/Mac/调试”“-F../../../第三方/Mac/NVidia” “-I/用户/matt/代码/MattsFeatureBranch/模块/用户 Notes/Mac/../../../Build Products/Mac/Debug/Plugins/include" -I../X-Platform -I../../../Common/Mac -I../../../Common/X-Platform -I../../../DLLs /ArcadiaCore/Mac -I../../../DLLs/ArcadiaCore/X-Platform“-I../../../第三方/Mac/Powerplant” -I/Developer/SDKs/MacOSX10.5.sdk/Developer/Headers/FlatCarbon“-I../../../第三方/X-Platform/boost_1_38_0” -I../../../DLLs/ArcadiaImaging/Mac -I../../../DLLs/ArcadiaImaging/X-Platform -I../../../DLLs/ArcadiaDatabase/Mac -I../../../DLLs/ArcadiaDatabase/X-平台 -I../../../DLLs/ArcadiaUI/Mac -I../../../DLLs/ArcadiaUI/X -平台“-I../../../第三方/Mac/Powerplant Extras” -I../../../DLLs/ArcadiaDevices/Mac -I../../../DLLs/ArcadiaDevices/X-Platform -I../../../DLLs/Arcadia3D/Mac -I../../../DLLs/Arcadia3D/X-Platform“-I/Users/matt/Code/MattsFeatureBranch/Modules/User Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module Bundle.build/DerivedSources/i386" “-I/用户/matt/代码/MattsFeatureBranch/模块/用户 Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module Bundle.build/DerivedSources" -fpermissive -fasm-blocks -include “/用户/马特/代码/MattsFeatureBranch/模块/用户 注释/Mac/../../../(中间)/Debug/SharedPrecompiledHeaders/XPrefix-acshmfbgvfwrdqbyayvgnckkypgr/XPrefix.h" -c“/Users/matt/Code/MattsFeatureBranch/Modules/用户注释/Mac/MUserNotesView.cpp”-o “/用户/马特/代码/MattsFeatureBranch/模块/用户 Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module Bundle.build/Objects-normal/i386/MUserNotesView.o"

We have a large Carbon based (PowerPlant) application that we are looking finally to port over to Cocoa. We will be doing this incrementally and a first step is to try to get a Cocoa view into a Carbon window.

The problem seems to be that when I use any of the functions from HICocoaView.h the application will not compile unless I switch the compiler from GCC 4.2 to GCC 4.0.

Using any compiler other than GCC 4.0 I get an error in XCode that the functions are unavailable e.g. "HICocoaViewCreate is unavailable".

I can't figure out why this won't work, will we have to switch to the older compiler or is there some setting we can change to get it to compile?

Any help or pointers to useful documentation on porting Carbon to Cocoa greatly appreciated. I've read through the old Carbon Cocoa Integration guide but it doesn't mention this.

Edit: As requested here's the output from the build for the gcc command line:-

/Developer/usr/bin/gcc-4.2 -x objective-c++ -arch i386
-fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wmissing-prototypes -Wreturn-type -Wunused-variable -Wunused-value -D__IMPRO_DEBUG_BUILD__ -isysroot /Developer/SDKs/MacOSX10.5.sdk -mfix-and-continue
-mmacosx-version-min=10.5 -gdwarf-2 "-I/Users/matt/Code/MattsFeatureBranch/Modules/User
Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module
Bundle.build/User Notes.hmap" -Wparentheses -Wno-conversion
-Wno-sign-compare -Wno-multichar -Wno-deprecated-declarations "-F/Users/matt/Code/MattsFeatureBranch/Modules/User
Notes/Mac/../../../Build Products/Mac/Debug/Plugins" "-F../../../Build
Products/Mac/Debug" "-F../../../Third Party/Mac/NVidia"
"-I/Users/matt/Code/MattsFeatureBranch/Modules/User
Notes/Mac/../../../Build Products/Mac/Debug/Plugins/include"
-I../X-Platform -I../../../Common/Mac -I../../../Common/X-Platform -I../../../DLLs/ArcadiaCore/Mac -I../../../DLLs/ArcadiaCore/X-Platform "-I../../../Third Party/Mac/Powerplant"
-I/Developer/SDKs/MacOSX10.5.sdk/Developer/Headers/FlatCarbon "-I../../../Third Party/X-Platform/boost_1_38_0"
-I../../../DLLs/ArcadiaImaging/Mac -I../../../DLLs/ArcadiaImaging/X-Platform -I../../../DLLs/ArcadiaDatabase/Mac -I../../../DLLs/ArcadiaDatabase/X-Platform -I../../../DLLs/ArcadiaUI/Mac -I../../../DLLs/ArcadiaUI/X-Platform "-I../../../Third Party/Mac/Powerplant Extras"
-I../../../DLLs/ArcadiaDevices/Mac -I../../../DLLs/ArcadiaDevices/X-Platform -I../../../DLLs/Arcadia3D/Mac -I../../../DLLs/Arcadia3D/X-Platform "-I/Users/matt/Code/MattsFeatureBranch/Modules/User
Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module
Bundle.build/DerivedSources/i386"
"-I/Users/matt/Code/MattsFeatureBranch/Modules/User
Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module
Bundle.build/DerivedSources" -fpermissive -fasm-blocks -include
"/Users/matt/Code/MattsFeatureBranch/Modules/User
Notes/Mac/../../../(Intermediates)/Debug/SharedPrecompiledHeaders/XPrefix-acshmfbgvfwrdqbyayvgnckkypgr/XPrefix.h"
-c "/Users/matt/Code/MattsFeatureBranch/Modules/User Notes/Mac/MUserNotesView.cpp" -o
"/Users/matt/Code/MattsFeatureBranch/Modules/User
Notes/Mac/../../../(Intermediates)/Debug/User Notes.build/Debug/Module
Bundle.build/Objects-normal/i386/MUserNotesView.o"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦明 2024-10-20 08:00:09

来自 10.5 和 10.6 SDK 中的 HICocoaView.h:

#if !__LP64__
extern OSStatus
HICocoaViewCreate(
  NSView *     inNSView,        /* can be NULL */
  OptionBits   inOptions,
  HIViewRef *  outHIView)                                                       AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
…
#endif  /* !__LP64__ */

这意味着 HICocoaViewCreate() 在 64 位 (LP64) 目标上不可用,即,如果您需要要使用此功能,您必须以 i386(或 PowerPC)为目标。

即使在支持 64 位的机器上运行,GCC 4.0 默认情况下也以 i386 为目标。另一方面,GCC 4.2 在 64 位机器上默认以 x86_64 为目标:

$ gcc-4.0 a.c; lipo -info a.out
Non-fat file: a.out is architecture: i386

$ gcc-4.2 a.c; lipo -info a.out
Non-fat file: a.out is architecture: x86_64

如果您想同时使用 HICocoaViewCreate() 和 GCC 4.2,请告诉它创建(并使用)32 位对象/通过传递 -arch i386 生成二进制文件。例如,

$ gcc-4.2 a.c -arch i386; lipo -info a.out
Non-fat file: a.out is architecture: i386

尽管 Carbon 的一部分可用于 64 位目标,但您会在 Carbon 开发人员的 64 位指南 HIToolbox 的大部分内容根本不可用。

至于从 Carbon 迁移到 Cocoa,很大程度上是一个全新的 Objective-C API。我不知道有任何简单的迁移指南,Peter Hosey 的Stack Overflow 上类似问题的回答值得一读。

From HICocoaView.h in both the 10.5 and the 10.6 SDK:

#if !__LP64__
extern OSStatus
HICocoaViewCreate(
  NSView *     inNSView,        /* can be NULL */
  OptionBits   inOptions,
  HIViewRef *  outHIView)                                                       AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
…
#endif  /* !__LP64__ */

This means that HICocoaViewCreate() is not available on 64-bit (LP64) targets, i.e., if you need to use this function you have to target i386 (or PowerPC).

GCC 4.0 targets i386 by default even when run on 64-bit capable machines. On the other hand, GCC 4.2 targets x86_64 by default on 64-bit machines:

$ gcc-4.0 a.c; lipo -info a.out
Non-fat file: a.out is architecture: i386

$ gcc-4.2 a.c; lipo -info a.out
Non-fat file: a.out is architecture: x86_64

If you want to use both HICocoaViewCreate() and GCC 4.2, tell it to create (and use) 32-bit objects/binaries by passing -arch i386. For instance,

$ gcc-4.2 a.c -arch i386; lipo -info a.out
Non-fat file: a.out is architecture: i386

Even though part of Carbon is available for 64-bit targets, you’ll notice in the 64-bit Guide for Carbon Developers that much of HIToolbox simply isn’t available.

As for migrating from Carbon to Cocoa, it’s a whole new Objective-C API for the most part. I’m not aware of any simple migration guide, and Peter Hosey’s answer to a similar question on Stack Overflow is worth reading.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文