Core Definitions¶
Small portable types and macros used throughout the project. More...
Types¶
| Name | |
|---|---|
| typedef uint8_t | CFBD_Bool Minimal boolean type (1 byte). |
| typedef CFBD_Bool(*)(void *self_handle, void *args) | SelfInitFunc Generic initialization callback signature for objects/components. |
| typedef void(*)(void *args) | PlainFunc Generic callback taking a single opaque argument and returning void. |
Defines¶
| Name | |
|---|---|
| CFBD_FALSE Integer value representing boolean false. |
|
| CFBD_TRUE Integer value representing boolean true. |
Detailed Description¶
Small portable types and macros used throughout the project.
Provides fundamental building blocks for the CFBD framework including platform-independent boolean type, callback function signatures, and related constants. These definitions are designed to be included widely across platform and application code without introducing unnecessary dependencies.
Types Documentation¶
typedef CFBD_Bool¶
Minimal boolean type (1 byte).
See:
Uses an unsigned 8-bit integer to represent boolean values. The explicit width helps keep ABI and header dependencies predictable on constrained targets. This type is portable across different platforms and compilers, making it suitable for use in headers that must be included in diverse contexts.
typedef SelfInitFunc¶
Generic initialization callback signature for objects/components.
Parameters:
- self_handle Pointer to the instance being initialized (may be NULL). Typically cast to the specific component type.
- args Opaque pointer to initialization parameters (may be NULL). Interpretation depends on the component implementation.
See:
Return: CFBD_Bool CFBD_TRUE on successful initialization, CFBD_FALSE if initialization failed.
Par: Example
CFBD_Bool initialize_component(void* self_handle, void* args) {
// Cast to actual type
ComponentState* component = (ComponentState*)self_handle;
ComponentInitArgs* init_args = (ComponentInitArgs*)args;
if (!component || !init_args) {
return CFBD_FALSE;
}
// Perform initialization
component->initialized = CFBD_TRUE;
return CFBD_TRUE;
}
Initialization callbacks receive an opaque self_handle which is typically a pointer to the object being initialized, and an opaque args pointer for passing platform or application-specific data. Implementations should return CFBD_TRUE on successful initialization or CFBD_FALSE otherwise.
This function pointer type enables a plugin-like architecture where components can be initialized through a common interface without requiring type knowledge at call sites.
typedef PlainFunc¶
Generic callback taking a single opaque argument and returning void.
Parameters:
- args Opaque pointer passed to the callback (may be NULL). Interpretation and lifetime ownership is defined by the code that registers and invokes the callback.
See: SelfInitFunc
Par: Example
void on_timer_tick(void* args) {
TimerContext* ctx = (TimerContext*)args;
ctx->tick_count++;
}
// Register callback
PlainFunc tick_handler = on_timer_tick;
tick_handler(timer_context);
Useful for simple callbacks, event handlers or deferred work items where no return status is required. This function pointer type enables flexible callback registration and invocation without type coupling.
Macros Documentation¶
define CFBD_FALSE¶
Integer value representing boolean false.
See: CFBD_Bool
This macro expands to 0, the standard false value.
define CFBD_TRUE¶
Integer value representing boolean true.
See: CFBD_Bool
This macro expands to 1, the standard true value.
Updated on 2026-02-03 at 13:21:55 +0000