您的位置:首页 > 运维架构 > Linux

【收藏帖】windows和Linux的数据类型对比

2015-12-04 10:36 441 查看
目前的疑问:

64位的Linux的long是64bit

64位的windows的long仍旧是32bit,why?

Platform SDK: 64-bit Windows Programming

Abstract Data Models

Every application and every operating system has an abstract data model. Many applications do not explicitly expose this data model, but the model guides the
way in which the application's code is written. In the 32-bit programming model (known as the ILP32 model), integer, long, and pointer data types are 32 bits in length. Most developers have used this model without realizing it. For the history of the Win32?
API, this has been a valid (although not necessarily safe) assumption to make.

In 64-bit Microsoft? Windows?, this assumption of parity in data type sizes is invalid.
Making all data types 64 bits in length would waste space, because most applications do not need the increased size.
However, applications do need pointers to 64-bit data, and they need the ability to have 64-bit data types in selected cases. These
considerations led to the selection of an abstract data model called LLP64 (or P64). In the LLP64 data model, only pointers expand to 64 bits; all other basic data types (integer and long) remain 32 bits in length.

Initially, most applications that run on 64-bit Windows will have been ported from 32-bit Windows. It is a goal that the same source, carefully written, should
run on both 32- and 64-bit Windows. Defining the data model does not make this task easier. However, ensuring that the data model affects only pointer data types is the first step. The second step is to define a set of new data types that allow developers
to automatically size their pointer-related data. This allows data associated with pointers to change size as the pointer size changes from 32 bits to 64 bits. Basic data types remain 32 bits in length, so there is no change in the size of data on the disk,
data shared over a network, or data shared through memory-mapped files. This relieves developers of much of the effort involved in porting 32-bit code to 64-bit Windows.

These new data types have been added to the Windows API header files. Therefore, you can start using the new types now. For more information, see The New Data
Types.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: