is char signed or unsigned by default on iOS?(在 iOS 上默认是 char 签名还是 unsigned?)
问题描述
char 在 iOS 上默认是有符号还是无符号?
Is char signed or unsigned by default on iOS?
(我认为这是一个很好回答的问题,但奇怪的是,谷歌没有发现任何有用的东西!)
(I thought this would've been a well answered question, but oddly google turned up nothing at all useful!)
推荐答案
在大多数情况下,char 在 ARM 上是未签名的(对于 性能原因)并在其他平台上签名.
In most cases, char is unsigned on ARM (for performance reasons) and signed on other platforms.
iOS 与 ARM 的常规约定不同,默认情况下为 char 签名.(特别是这与 Android 不同,where 代码在ndk中编译默认为无符号字符.)
iOS differs from the normal convention for ARM, and char is signed by default. (In particular this differs from 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 上检查)
This can be changed in xcode, there is a 'char' Type is unsigned option (which defaults to off). If this is changed to "yes", xcode will pass -funsigned-char to llvm. (Checked on xcode 5.0.2)
iOS 不同的原因在 iOS ABI 函数调用指南:ARM64 函数调用约定,简单来说就是:
The reason why iOS differs is mentioned in iOS ABI Function Call Guide: ARM64 Function Calling Conventions, which says simply:
在 iOS 中,与其他 Darwin 平台一样,char 和 wchar_t 都是签名类型.
In iOS, as with other Darwin platforms, both char and wchar_t are signed types.
这篇关于在 iOS 上默认是 char 签名还是 unsigned?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 iOS 上默认是 char 签名还是 unsigned?
基础教程推荐
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
