char
在 iOS 上默认是有符号的还是无符号的?
(我认为这是一个很好回答的问题,但奇怪的是谷歌没有找到任何有用的东西!)
最佳答案
在大多数情况下,char
在 ARM 上是无符号的(对于 performance reasons ),而在其他平台上是有符号的。
iOS 不同于 ARM 的常规约定,默认情况下对 char 进行签名。 (特别是这不同于 Android,where code compiled in the ndk defaults to unsigned char。)
这可以在 xcode 中更改,有一个 'char' Type is unsigned
选项(默认为关闭)。如果将其更改为“yes”,xcode 会将 -funsigned-char
传递给 llvm。 (在 xcode 5.0.2 上检查过)
iOS ABI Function Call Guide: ARM64 Function Calling Conventions 中提到了 iOS 不同的原因。 ,它简单地说:
In iOS, as with other Darwin platforms, both char and wchar_t are signed types.
关于ios - iOS 上的 char 是有符号的还是无符号的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20576300/