b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

pascal 视频教程_pascal和basic_pascal选择排序(117)

电脑杂谈  发布时间:2016-12-28 07:02:37  来源:网络整理

当一个记录类型在{$A+}状态下声明,并且没有使用packed修饰字时,这是一个未压缩的(unpacked)记录类型。此时,记录的各字段被优化排列,以使CPU更有效地进行访问。排列规则由字段的类型控制,每一种数据类型有固定的排列规则,并且由编译器自动计算。排列规则可以是1,2,4或者8,它表示每一个类型被存储的字节边界,以得到最优化的访问。下表列出了所有数据类型的排列规则。 类型

有序类型

实数

数组

记录

集合 字节对齐 类型的大小(1、2、4或者8) 2 for Real48, 4 for Single, 8 for Double and Extended same as the element type of the array. the largest alignment of the fields in the record size of the type if 1, 2, or 4, otherwise 1 短字符串其它所有类型To ensure proper alignment of the fields in an unpacked record type, the compiler inserts an unused byte before fields with an alignment of 2, and up to three unused bytes before fields with an alignment of 4, if required. Finally, the compiler rounds the total size of the record upward to the byte boundary specified by the largest alignment of any of the fields.

当在{$A?}状态下声明记录类型,或者当声明包含packed修饰符时,记录的字段没有被优化排列,它们被连续存放。这样一个压缩(packed)记录,它的大小是所有字段的大小之和。因为数据排列会改变,所以,当把记录结构写入磁盘,或者通过内存把记录结构传递给由不同版本的编译器编译的模块时,使用压缩记录是个好主意。

File types(文件类型)

文件类型表示为记录,类型文件和无类型文件占用332字节,它们的布局如下:

type

TFileRec = packed record

Handle: Integer;

Mode: word;

Flags: word;

case Byte of

0: (RecSize: Cardinal);

1: (BufSize: Cardinal;

BufPos: Cardinal;

BufEnd: Cardinal;

BufPtr: PChar;

OpenFunc: Pointer;

InOutFunc: Pointer;

FlushFunc: Pointer;

CloseFunc: Pointer;

- 157 -

Memory management

UserData: array[1..32] of Byte;

Name: array[0..259] of Char; );

end;

文本文件占用460字节,它的布局如下:

type

TTextBuf = array[0..127] of Char;

TTextRec = packed record

Handle: Integer;

Mode: word;

Flags: word;

BufSize: Cardinal;


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-23665-117.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 金兴聪
      金兴聪

      但是诉讼费真的很贵

    热点图片
    拼命载入中...