gpt4 book ai didi

cocoa - "Standard (32/64-bit Intel)"Architecture 作为目标实际上意味着什么?

转载 作者:行者123 更新时间:2023-12-03 16:17:21 25 4
gpt4 key购买 nike

我有一个应用程序,其中添加了一些新功能。这是在 Debug模式下进行测试的,但在编译发布时引入了许多错误。

一些侦探工作表明这些是由在 NSView 类和 CALayer 类之间转换点的调用引起的,例如

- (NSPoint)convertPoint:(NSPoint)aPoint fromView:(NSView *)aView
- (CGPoint)convertPoint:(CGPoint)aPoint toLayer:(CALayer *)layer
error: incompatible type for argument 1 of 'convertPoint:toLayer:'

尝试纠正此问题导致将一组错误替换为另一组错误,我在 NSPoint 中发现了问题:-

Prior to Mac OS X v10.5 the coordinates were represented by float values rather than CGFloat values. When building for 64 bit systems, or building 32 bit like 64 bit, NSPoint is typedef’d to CGPoint.

我一直在编译默认的“标准(32/64 位英特尔)”架构,将其更改为“64 位英特尔”解决了问题。我可以通过在 NSPoint 和 CGPoint 之间包含显式转换来解决该问题,尽管这很笨拙(并且在 64 位中是不必要的)。

我试图找出“标准(32/64 位英特尔)”架构的实际含义,但一无所获。我唯一能找到的是这个:-

A list of the architectures for which the product will be built. This is usually set to a predefined build setting provided by the platform. If more than one architecture is specified, a universal binary will be produced.

查看应用程序包似乎没有显示标准(32/64 位 Intel)和 64 位 Intel 之间有太大差异。

任何人都可以阐明这一点吗?尝试在面向 10.6 或更高版本的应用程序中生成“标准(32/64 位英特尔)”有什么意义吗?

最佳答案

A bit of detective work showed these were caused by calls to convert a point between the NSView class and the CALayer class e.g.

- (NSPoint)convertPoint:(NSPoint)aPoint fromView:(NSView *)aView
- (CGPoint)convertPoint:(CGPoint)aPoint toLayer:(CALayer *)layer
error: incompatible type for argument 1 of 'convertPoint:toLayer:'

Attempts to correct this resulted in exchanging one set of errors for another, and I discovered the problem in NSPoint:-

Prior to Mac OS X v10.5 the coordinates were represented by float values rather than CGFloat values. When building for 64 bit systems, or building 32 bit like 64 bit, NSPoint is typedef’d to CGPoint.

正确。构建 32 位时,NSPoint是一个独立的结构,与 CGPoint 不兼容根据 C 的说法,尽管它们实际上以相同的格式保存相同的值。

“像 64 位一样构建 32 位”部分是一个您可以定义的宏,它使得该部分和其他一些内容的定义方式与 64 位构建中的相同。该宏的名称是 NS_BUILD_32_LIKE_64 ;将其定义为 1打开该功能。我推荐它。

I had been compiling for the default "Standard (32/64-bit Intel)" Architecture changing this to "64-bit Intel" resolved the problem.
I could resolve the problem by including explicit conversions between NSPoint and CGPoint, although this is clumsy (and unnecessary in 64-bit).

是的。这是另外两个解决方案。

I tried to discover what "Standard (32/64-bit Intel)" Architecture actually means, but drew a blank. The only thing I could find was this:-

A list of the architectures for which the product will be built. This is usually set to a predefined build setting provided by the platform. If more than one architecture is specified, a universal binary will be produced.

这是架构 ( ARCHS ) 设置的一般定义,而不是特定值。

Poking around in Application Packages did not seem to show much difference between Standard (32/64-bit Intel) and 64-bit Intel.

Can anyone shed any light on this, and is there any point in trying to produce "Standard (32/64-bit Intel)" in an Application targeting 10.6 or later?

64 位 Mac OS X 中发生了一些变化,包括:

  • 该语言中出现了一些新功能,例如非脆弱实例变量。这使您可以在运行时添加实例变量,并且更有用的是,在实现文件中隐藏实例变量声明,而不是在 header 中公开它们。
  • 几何结构的定义发生了变化。这就是你遇到的情况。您现在可以自由地传递NSPoint其中 CGPoint是预期的,反之亦然,对于其他结构也是如此。
  • 类似地,许多以前获取或返回多个点作为 float 的方法现在将其作为 CGFloat 获取或返回,可以定义为double .
  • NSUInteger定义为unsigned long ,不是unsigned int ,对于NSInteger也是如此。 .

其中一些内容与 32 位 OS X 完全不兼容,例如语言更改;您可以编写一个无法为 32 位构建的程序。

其他破损情况较软。如上所述,一些定义在 64 位中发生了更改,但为了兼容性,较旧的定义仍然是 32 位中的默认定义,但您可以使用上述宏来切换它们。

那么为什么这很重要?

2006 年底/2007 年初之前推出的 Mac 型号仅支持 32 位 Intel 架构(IA32,又名 i386)。大约 2007 年初,Apple 开始推出也支持 64 位架构 (x86-64) 的 Mac。

在 64 位硬件上运行的 Mac OS X(到目前为止)始终可以运行 32 位软件,但在 32 位硬件上运行的 Mac OS X 只能运行 32 位软件。 Mac OS X 本身是为两者而构建的,直到 Lion;现在,它需要 64 位 Mac。

因此,构建 32 位的唯一原因是您希望支持五年前的硬件(例如,如果您拥有该硬件)。如果您希望获得较新的语言功能并且不介意放弃拥有五年前 Mac 的客户,那么就只使用 64 位,不要回头。

当然,这是假设您没有任何手写的 i386 汇编代码或使用 Carbon 中不再支持的函数的代码。如果您这样做,那么这就是坚持使用 32 位的另一个潜在动机。请注意,Mac OS X 中对 32 位程序的支持有一天可能会消失。

苹果有相关文档:

关于cocoa - "Standard (32/64-bit Intel)"Architecture 作为目标实际上意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8371926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com