https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40013501-CH1-SW1

Table 1-1  Size and alignment of integer data types in OS X and iOS

Integer data type

ILP32 size

ILP32 alignment

LP64 size

LP64 alignment

char

1 byte

1 byte

1 byte

1 byte

BOOLbool

1 byte

1 byte

1 byte

1 byte

short

2 bytes

2 bytes

2 bytes

2 bytes

int

4 bytes

4 bytes

4 bytes

4 bytes

long

4 bytes

4 bytes

8 bytes

8 bytes

long long

8 bytes

4 bytes

8 bytes

8 bytes

pointer

4 bytes

4 bytes

8 bytes

8 bytes

size_t

4 bytes

4 bytes

8 bytes

8 bytes

NSInteger

4 bytes

4 bytes

8 bytes

8 bytes

CFIndex

4 bytes

4 bytes

8 bytes

8 bytes

fpos_t

8 bytes

4 bytes

8 bytes

8 bytes

off_t

8 bytes

4 bytes

8 bytes

8 bytes

Table 1-2  Size of floating-point data types in OS X and iOS

Floating-point type

ILP32 size

LP64 size

float

4 bytes

4 bytes

double

8 bytes

8 bytes

CGFloat

4 bytes

8 bytes

数据类型改变:

指针类型由4字节改为8字节;

long,size_t,NSInteger,CFIndex 变为8字节;

CGFloat 由4字节变为8字节。

Summary

At a high level, to make your code 64-bit clean, you must do the following:

  • Avoid assigning 64-bit long integers to 32-bit integers.

  • Avoid assigning 64-bit pointers to 32-bit integers.

  • Avoid pointer and long integer truncation during arithmetic operations (or other arithmetic problems caused by the change in integer types).

  • Fix alignment issues caused by changes in data type sizes. (内存对齐问题)

  • Ensure that memory structures that are shared between the 32-bit and 64-bit runtimes share a similar layout.

  • Rewrite any assembly language code so that your code uses the new 64-bit opcodes and runtime.

  • Avoid casting variadic functions to functions that take a fixed number of parameters, or vice versa.(变参函数 和 定参函数之间的转换)

Common Memory Usage Problems

1  Foundation Objects May Be Expensive for Small Payloads    使用NSDictionary、NSArray等对象保存少量数据时耗费更多的内存。

2 Choose a Compact Data Representation   使用紧凑的数据结构,少一些变量(一些变量可以由某个变量计算得出)

3 Pack Data Structures  注意内存对齐问题,编译器可能会添加额外的补齐空间。

4 Use Fewer Pointers 64-bit 中指针占用更多的内存空间。

5 Memory Allocations Are Padded to Preserve Alignment

When allocating memory for C structs, it may be more efficient for you to allocate a few large blocks of memory instead of allocating memory for each individual struct.

6 Cache Only When You Need To

Converting Your App to a 64-Bit Binary

1  Do Not Cast Pointers to Integers

2  Use Data Types Consistently

使用数据类型要保持一致。

枚举也是有类型的。

NSIntger,CGFloat 已经变成64位了,与int、float进行计算时要注意。

3  Be Careful When Performing Integer Computations

注意有符号和无符号数:有符号数和无符号数进行计算得到的结果是无符号的;

  1. Unsigned values are zero extended (not sign extended) when promoted to a larger type.(无符号数 转换成更大的类型时 用0补齐额外的位数)

  2. Signed values are always sign extended when promoted to a larger type, even if the resulting type is unsigned.(有符号数 转换成更大的类型时 用符号位补齐额外的位数)

  3. Constants (unless modified by a suffix, such as 0x8L) are treated as the smallest size that will hold the value. Numbers written in hexadecimal may be treated by the compiler as intlong, and long long types and may be either signed or unsigned types. Decimal numbers are always treated as signed types.(常量的对待,十进制为有符号数)

  4. The sum of a signed value and an unsigned value of the same size is an unsigned value.

位操作Bits and Bitmasks:

  • If you want the mask value to contain zeros in the upper 32 bits in the 64-bit runtime, the usual fixed-width mask works as expected, because it will be extended in an unsigned fashion to a 64-bit quantity.

  • If you want the mask value to contain ones in the upper bits, write the mask as the bitwise inverse of its inverse

4 Create Data Structures with Fixed Size and Alignment

使用明确长度的int类型:

able 2-1  C99 explicit integer types

Type

Range

int8_t

-128 to 127

int16_t

-32,768 to 32,767

int32_t

-2,147,483,648 to 2,147,483,647

int64_t

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

uint8_t

0 to 255

uint16_t

0 to 65,535

uint32_t

0 to 4,294,967,295

uint64_t

0 to 18,446,744,073,709,551,615

5 Allocate Memory Using sizeof

6 Update Format Strings to Support Both Runtimes

7  Take Care with Functions and Function Pointers

8  Use the Built-in Synchronization Primitives

9  Never Hard-Code the Virtual Memory Page Size

10 Go Position Independent

11 Don’t Forget your 32-bit Version

12 Make Your App Run Well in the 32-Bit Runtime

convert app to 64-bit for ios7的更多相关文章

  1. 让app在ios6上具有ios7的扁平效果

    使用cocoapods在工程中加入UI7Kit,关于UI7Kit请自行google. 加入到工程 如果没安装cocoapods,则安装.(http://www.cocoapods.org) 安装方法: ...

  2. iOS7 人机界面设计指南

    iOS7 人机界面设计指南     苹果在WWDC 2013大会上发布了iOS 7,新系统一改5年来的拟物路线,在乔纳森•艾维的主导下,加入了更多的“扁平化”和“极简”现代设计元素. iOS7系统界面 ...

  3. iOS-----GitHub上比较齐全的iOS 工具和App

    Github-iOS 工具 和 App   系统基础库 Category/Util sstoolkit 一套Category类型的库,附带很多自定义控件 功能不错-       BFKit 又一套Ca ...

  4. iOS:让64位兼容百度地图

    当使用了百度地图sdk的app在64位机中运行时,会出现No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_6 ...

  5. [翻译] SoundManager 音频管理器

    SoundManager 音频管理器 https://github.com/nicklockwood/SoundManager Purpose SoundManager is a simple cla ...

  6. iOS 7 新特性

      iOS7更新了很多引人注目的功能.用户界面完全重新设计了.iOS7为开发2D,2.5D游戏引入了全新的动画系统.加强多线程,点对点连接,以及许多其他重要的功能让iOS7成为有史以来最有意义的一次发 ...

  7. 怎样将word文件转化为Latex文件:word-to-latex-2.56具体解释

    首先推荐大家读一读这篇博文:http://blog.csdn.net/ibingow/article/details/8613556 --------------------------------- ...

  8. LVM卷管理

    一.LVM是做什么的 LVM ( Logical Volume Manager ,逻辑卷管理器)LVM 是建立在磁盘和分区之上的一个逻辑层,用来提高磁盘分区管理的灵活性.LVM 可以对磁盘分区按照组的 ...

  9. 开源 iOS 项目分类索引大全 - 待整理

    开源 iOS 项目分类索引大全 GitHub 上大概600个开源 iOS 项目的分类和介绍,对于你挑选和使用开源项目应该有帮助 系统基础库 Category/Util sstoolkit 一套Cate ...

随机推荐

  1. WIN32读写INI文件方法

      在程序中经常要用到设置或者其他少量数据的存盘,以便程序在下一次执行的时候可以使用,比如说保存本次程序执行时窗口的位置.大小.一些用户设置的 数据等等,在 Dos 下编程的时候,我们一般自己产生一个 ...

  2. RDIFramework.NET平台代码生成器V1.0发布(提供下载)

    RDIFramework.NET平台代码生成器V1.0发布(提供下载)   RDIFramework.NET(.NET快速开发整合框架)框架做为信息化系统快速开发.整合的框架,其目的一至是给用户和开发 ...

  3. Java基础知识强化88:BigDecimal类之BigDecimal类引入和概述 以及 BigDecimal的使用(加减乘除)

    1. BigDecimal类概述: 由于在运算的时候,float类型和double很容易丢失精度.所以为了能够精确的表达.计算浮点数,Java提供了BigDecimal. BigDecimal:不可变 ...

  4. Android(java)学习笔记252:ContentProvider使用之内容观察者01

    1. 内容观察者 不属于四大组件,只是内容提供者ContentProvider对应的小功能. 如果发现数据库内容变化了,就会立刻观察到. 下面是逻辑图:       当A应用中银行内部的数据发生变化的 ...

  5. 在linux后台执行脚本

    1. 使用&符号在后台执行命令 你可以在Linux命令或者脚本后面增加&符号,从而使命令或脚本在后台执行,例如:. $ ./my-shell-script.sh & 2. 使用 ...

  6. Tomcat 加入windows 服务自启动设置

    基于J2ee技术开发,可以运行在Tomcat.weblogic.websphere等J2ee应用服务器上,对于一般访问量不是很高的客户我们推荐使用Tomcat(开源免费),一般情况下Tomcat服务需 ...

  7. MyEclipse修改servlet模版

    找到myeclipse安装目录中的 然后把这个jar包复制到桌面 以压缩包的方式打开 之后保存, 然后把修改的这个jar包放到刚开的路径,替换已经存在的! 完成!

  8. MyKTV项目,走起!

    MyKTV项目,走起! 第一部分:这个项目对于新手来说有一点难度,但是当你理清类之间的关系和怎样去实现功能后就会感觉轻松很多. 话不多说,先上类图: 接着是数据库表间关系: 本项目要实现以下功能: 明 ...

  9. (转)Web Service入门简介(一个简单的WebService示例)

    Web Service入门简介 一.Web Service简介 1.1.Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从I ...

  10. 学习日记-----ORM

    ORM ORM(Object Relation Mapping)对象关系映射 实质:将数据库中 的业务数据用对象的形式表现出来,使用ORM在业务逻辑层和数据访问层之间充当桥梁 核心原则: 简单性 传达 ...