Skip to content

Function macros

Finalspace edited this page May 29, 2026 · 1 revision

This category contains several useful macro functions. More...

Data Structures

Type Name
union fplEndianess
Byte-order probe union that overlays a 32-bit integer with its raw bytes. More...

Macros

Type Name
#define FPL_NOT_IMPLEMENTED
Crashes the application via a null-pointer write.
#define fplArrayCount(arr)
Returns the element count from a static array.
#define fplClearStruct(ptr)
Clears the given struct pointer to zero.
#define fplCopyStruct(src, dst)
Copies the given source struct into the destination struct.
#define fplGetAlignedSize(size, alignment)
Returns the given size, extended to satisfy the given alignment boundary.
#define fplGetAlignmentOffset(value, alignment)
Returns the offset for the value to satisfy the given alignment boundary.
#define fplGetEndianess32()
Returns the unsigned 32-bit integer value that represents the current platform endianness, built from the byte sequence (0, 1, 2, 3).
#define fplGigaBytes(value)
Returns the number of bytes for the given gigabytes.
#define fplIsAligned(ptr, alignment)
Returns true when the given pointer address is aligned to the given alignment.
#define fplIsBigEndian()
Gets a value indicating whether the current platform is big-endian or not.
#define fplIsBitSet(value, bit)
Returns true when the given value has the given bit set.
#define fplIsLittleEndian()
Gets a value indicating whether the current platform is little-endian or not.
#define fplIsMaskSet(value, mask)
Returns true when the given mask is set in the value.
#define fplIsPowerOfTwo(value)
Returns true when the given value is a power of two.
#define fplKiloBytes(value)
Returns the number of bytes for the given kilobytes.
#define fplMax(a, b)
Returns the biggest value of A and B.
#define fplMegaBytes(value)
Returns the number of bytes for the given megabytes.
#define fplMin(a, b)
Returns the smallest value of A and B.
#define fplOffsetOf(type, field)
Returns the offset in bytes for the specified structure type and field name.
#define fplStackAllocate(size)
Manually allocate the number of specified bytes of memory on the stack.
#define fplStructField
Defines a single field in a struct.
#define fplStructInit
Initializes a struct by the given type.
#define fplStructSet
Overwrites the value of the given struct to a new value.
#define fplTeraBytes(value)
Returns the number of bytes for the given terabytes.
#define fplZeroInit
Initializes a struct to zero.

Enumerations

Type Name
enum fplEndianessType { fplEndianessType_Little , fplEndianessType_Big }
Sentinel values used to detect the byte order of the host platform at runtime. More...

Detailed Description

This category contains several useful macro functions.

Macro Definition Documentation

FPL_NOT_IMPLEMENTED

#define FPL_NOT_IMPLEMENTED

Crashes the application via a null-pointer write.

Marks code paths that are not implemented.

Definition at line 3293 of file final_platform_layer.h.

fplArrayCount

#define fplArrayCount ( arr)

Returns the element count from a static array.

This should ideally produce a compile error when passing a pointer to it.

Parameters

Direction Parameter Description
[in] arr Array to count elements.

Returns: Element count.

Definition at line 3513 of file final_platform_layer.h.

fplClearStruct

#define fplClearStruct ( ptr)

Clears the given struct pointer to zero.

Parameters

Direction Parameter Description
[in] ptr Pointer to the struct.

Definition at line 3486 of file final_platform_layer.h.

fplCopyStruct

#define fplCopyStruct ( src, dst )

Copies the given source struct into the destination struct.

Parameters

Direction Parameter Description
[in] src Source struct pointer.
[out] dst Destination struct pointer.

Definition at line 3494 of file final_platform_layer.h.

fplGetAlignedSize

#define fplGetAlignedSize ( size, alignment )

Returns the given size, extended to satisfy the given alignment boundary.

Parameters

Direction Parameter Description
[in] size Size to align.
[in] alignment Alignment boundary.

Returns: Aligned size.

Definition at line 3358 of file final_platform_layer.h.

fplGetAlignmentOffset

#define fplGetAlignmentOffset ( value, alignment )

Returns the offset for the value to satisfy the given alignment boundary.

Parameters

Direction Parameter Description
[in] value Value to align.
[in] alignment Alignment boundary.

Returns: Offset to satisfy the alignment boundary.

Definition at line 3349 of file final_platform_layer.h.

fplGetEndianess32

#define fplGetEndianess32 ( )

Returns the unsigned 32-bit integer value that represents the current platform endianness, built from the byte sequence (0, 1, 2, 3).

Returns: Unsigned 32-bit integer endianness probe value.

Definition at line 3479 of file final_platform_layer.h.

fplGigaBytes

#define fplGigaBytes ( value)

Returns the number of bytes for the given gigabytes.

Parameters

Direction Parameter Description
[in] value Value in gigabytes.

Returns: Number of bytes.

Definition at line 3408 of file final_platform_layer.h.

fplIsAligned

#define fplIsAligned ( ptr, alignment )

Returns true when the given pointer address is aligned to the given alignment.

Parameters

Direction Parameter Description
[in] ptr Pointer to check.
[in] alignment Alignment boundary.

Returns: True if the pointer is aligned, false otherwise.

Definition at line 3367 of file final_platform_layer.h.

fplIsBigEndian

#define fplIsBigEndian ( )

Gets a value indicating whether the current platform is big-endian or not.

Returns: Returns true if the platform is big-endian, false otherwise.

Definition at line 3465 of file final_platform_layer.h.

fplIsBitSet

#define fplIsBitSet ( value, bit )

Returns true when the given value has the given bit set.

Parameters

Direction Parameter Description
[in] value Value to check.
[in] bit Bit position to check.

Returns: True if the bit is set, false otherwise.

Definition at line 3384 of file final_platform_layer.h.

fplIsLittleEndian

#define fplIsLittleEndian ( )

Gets a value indicating whether the current platform is little-endian or not.

Returns: Returns true if the platform is little-endian, false otherwise.

Definition at line 3472 of file final_platform_layer.h.

fplIsMaskSet

#define fplIsMaskSet ( value, mask )

Returns true when the given mask is set in the value.

Parameters

Direction Parameter Description
[in] value Value to check.
[in] mask Bit mask to check.

Returns: True if the mask is set, false otherwise.

Definition at line 3425 of file final_platform_layer.h.

fplIsPowerOfTwo

#define fplIsPowerOfTwo ( value)

Returns true when the given value is a power of two.

Parameters

Direction Parameter Description
[in] value Value to check.

Returns: True if the value is a power of two, false otherwise.

Definition at line 3375 of file final_platform_layer.h.

fplKiloBytes

#define fplKiloBytes ( value)

Returns the number of bytes for the given kilobytes.

Parameters

Direction Parameter Description
[in] value Value in kilobytes.

Returns: Number of bytes.

Definition at line 3392 of file final_platform_layer.h.

fplMax

#define fplMax ( a, b )

Returns the biggest value of A and B.

Parameters

Direction Parameter Description
[in] a First value.
[in] b Second value.

Returns: Biggest value.

Definition at line 3540 of file final_platform_layer.h.

fplMegaBytes

#define fplMegaBytes ( value)

Returns the number of bytes for the given megabytes.

Parameters

Direction Parameter Description
[in] value Value in megabytes.

Returns: Number of bytes.

Definition at line 3400 of file final_platform_layer.h.

fplMin

#define fplMin ( a, b )

Returns the smallest value of A and B.

Parameters

Direction Parameter Description
[in] a First value.
[in] b Second value.

Returns: Smallest value.

Definition at line 3531 of file final_platform_layer.h.

fplOffsetOf

#define fplOffsetOf ( type, field )

Returns the offset in bytes for the specified structure type and field name.

Parameters

Direction Parameter Description
[in] type Structure type.
[in] field Field name.

Returns: Offset in bytes.

Definition at line 3522 of file final_platform_layer.h.

fplStackAllocate

#define fplStackAllocate ( size)

Manually allocate the number of specified bytes of memory on the stack.

Parameters

Direction Parameter Description
[in] size Number of bytes to allocate.

Returns: A pointer to the start of the stack memory.

Note: Use this very carefully, as it may break stack memory!

Definition at line 3555 of file final_platform_layer.h.

fplStructField

#define fplStructField

Defines a single field in a struct.

Parameters

Direction Parameter Description
[in] type The identifier of the struct.
[in] name The name of the field.
[in] ... Value of the field from variable arguments.

Returns: The constructed field.

Definition at line 3340 of file final_platform_layer.h.

fplStructInit

#define fplStructInit

Initializes a struct by the given type.

Parameters

Direction Parameter Description
[in] type The identifier of the struct.
[in] ... Value of the struct from variable arguments without braces in between.

Returns: The initialized struct command.

Definition at line 3330 of file final_platform_layer.h.

fplStructSet

#define fplStructSet

Overwrites the value of the given struct to a new value.

Parameters

Direction Parameter Description
[in/out] ptr The reference to the output struct.
[in] type The identifier of the struct.
[in] value The new value that is written to the struct reference.

Definition at line 3321 of file final_platform_layer.h.

fplTeraBytes

#define fplTeraBytes ( value)

Returns the number of bytes for the given terabytes.

Parameters

Direction Parameter Description
[in] value Value in terabytes.

Returns: Number of bytes.

Definition at line 3416 of file final_platform_layer.h.

fplZeroInit

#define fplZeroInit

Initializes a struct to zero.

Returns: The command that initializes a struct to zero, e.g. {0} or {}.

Definition at line 3312 of file final_platform_layer.h.

Enumeration Type Documentation

fplEndianessType

enum fplEndianessType

Sentinel values used to detect the byte order of the host platform at runtime.

Name Description
fplEndianessType_Little Little-endian type.
fplEndianessType_Big Big-endian type.

Definition at line 3435 of file final_platform_layer.h.

Final Platform Layer

Pages

Topics

Data Structures

Clone this wiki locally