Revision [14156]

This is an old revision of KeyPgField made by YetiFoot on 2009-06-11 22:18:07.

 

FIELD


Specifies alignment.

Syntax:
KeyPgType Type typename Field = { 1 | 2 | 4 }
...
End KeyPgType Type

Description:
The following information is likely incorrect, FB follows the GCC padding rules, which these next sentences do not describe. The source file symb-struct.bas of the compiler shows the exact method.
A KeyPgType Type variable has its fields aligned to the word length of the system, 4 bytes presently. Field modifies the default alignment to one byte (Field 1) or two bytes (Field 2). This helps FreeBASIC maintain compatibility with structures created in other languages.

Examples:
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

'Open up bmp.bmp and get its header data:
'Note: Will not work without a bmp.bmp to load . . .
Open "bmp.bmp" For Binary As #1

    Get #1, , bmp_header
   
Close #1

Print bmp_header.biWidth, bmp_header.biHeight

Sleep


Dialect Differences:
Differences from QB:

See also:
Back to User Defined Types
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode