在 iOS 上默认是 char 签名还是 unsigned?

is char signed or unsigned by default on iOS?(在 iOS 上默认是 char 签名还是 unsigned?)
本文介绍了在 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)