Repository navigation
Field
Home › User Defined Types › Field
Specifies field alignment.
Type|Union typename Field = { 1 | 2 | 4 }
...
End Type|UnionField can be used to pack Types or Unions more tightly than the default layout. The most commonly used value is Field = 1, which causes the Type or Union to be packed as tightly as possible, without any padding bytes being added between the fields or at the end of the Type. Field can only be used to decrease field alignment, but it cannot be used to increase it. In order to add padding bytes, a Union with appropriate members could be used instead.
- In the -lang qb dialect, the compiler assumes
Field = 1by default, if no otherFieldwas specified, causing all structures to be tightly packed, without added padding, as in QB.
- In QB
Fieldwas used to define fields in a file buffer at run time. This feature is not implemented in FB, so the keyword has been redefined. To define fields in a file buffer,Typesmust be used.
Type bitmap_header Field = 1
bfType As UShort
bfsize As ULong
bfReserved1 As UShort
bfReserved2 As UShort
bfOffBits As ULong
biSize As ULong
biWidth As ULong
biHeight As ULong
biPlanes As UShort
biBitCount As UShort
biCompression As ULong
biSizeImage As ULong
biXPelsPerMeter As ULong
biYPelsPerMeter As ULong
biClrUsed As ULong
biClrImportant As ULong
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
SleepCategory: User Defined Types
Kind: type
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing