<分区>
在新的 Apple Swift 文档中,它说:
Int
In most cases, you don’t need to pick a specific size of integer to use in your code. Swift provides an additional integer type, Int, which has the same size as the current platform’s native word size:
On a 32-bit platform, Int is the same size as Int32. On a 64-bit platform, Int is the same size as Int64. Unless you need to work with a specific size of integer, always use Int for integer values in your code. This aids code consistency and interoperability. Even on 32-bit platforms, Int can store any value between -2,147,483,648 and 2,147,483,647, and is large enough for many integer ranges.
我可以理解,当使用用“Int”定义的 API 时,您应该使用它们。
但对于我自己的代码,我一直严格要求在 C 语言中使用 stdint header 使用适当的位大小类型。我的想法是我会尝试减少歧义。然而,Apple 的人非常聪明,我想知道我是否遗漏了什么,因为这不是他们推荐的。