指定字段对齐。
语法
说明
Field可以比
默认布局更紧密地打包
Types或
Unions.最常用的值是
Field = 1,这使
Type或
Union尽可能紧凑地打包,而不会在字段之间或在
Type结尾添加任何填充字节。
Field只能用于减少字段对齐,但不能用于增加字段对齐。为了添加填充字节,可以使用具有适当成员的
Union.
例子
Type bitmap_header Field = 1
bfType As UShort
bfsize As UInteger
bfReserved1 As UShort
bfReserved2 As UShort
bfOffBits As UInteger
biSize As UInteger
biWidth As UInteger
biHeight As UInteger
biPlanes As UShort
biBitCount As UShort
biCompression As UInteger
biSizeImage As UInteger
biXPelsPerMeter As UInteger
biYPelsPerMeter As UInteger
biClrUsed As UInteger
biClrImportant As UInteger
End Type
Dim bmp_header As bitmap_header
'打开bmp.bmp并获取其头数据:
'注意:如果没有bmp.bmp加载,将无法正常工作。..
Open "bmp.bmp" For Binary As #1
Get #1, , bmp_header
Close #1
Print bmp_header.biWidth, bmp_header.biHeight
Sleep
方言差异
- 在-lang qb 方言中,如果没有指定其他领域,则默认情况下,编译器假定Field = 1,导致所有结构都没有添加填充,在QB。
与QB差别
- 在QB 领域中,用于在运行时定义文件缓冲区中的字段。此函数在FB中未实现,因此关键字已被重新定义。要定义文件缓冲区中的字段,必须使用类型s.
参考