Repository navigation
Sizeof
Home › Miscellaneous Keywords › SizeOf
Returns the size of a variable or type in bytes.
SizeOf ( variable | DataType )The SizeOf operator returns an Integer value: the number of bytes taken up by a variable or DataType (including the data fields of a UDT).
When used with fixed-length strings (including fixed-length ZStrings and WStrings) it will return the number of bytes they use, and when used with variable-length strings, it will return the size of the string descriptor.
(it is equal to Len only when used with fixed-length strings of STRING*N type)
If there is both a user defined type and a variable visible with the same name in the current scope, the user defined type takes precedence over the variable. To ensure that the SizeOf takes the variable instead of the user defined type, wrap the argument to SizeOf with parentheses to force it to be seen as an expression. For example Sizeof((variable)).
Note: When used with array names, SizeOf returns the size of the array dadatype, but not the total size of the array. This differs from its behavior in C, where arrays could only be a fixed size, and sizeof() would return the number of it used.
For clarity, it is recommended that you avoid this potential confusion, and use SizeOf on the array datatype doing SizeOf(Typeof(array)), rather than the array name only doing SizeOf(array).
Remark: When used with a dereferenced z/wstring pointer, SizeOf always returns the number of bytes taken up by one z/wstring character.
- Not available in the -lang qb dialect unless referenced with the alias
__Sizeof.
- New to FreeBASIC
Print SizeOf(Byte) ' returns 1
Type bar
a As Integer
b As Double
End Type
Dim foo As bar
Print SizeOf(foo)Category: Miscellaneous Keywords
Kind: keyword
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