Skip to main content
CFunction wraps a raw C function pointer as a callable TypeScript function.

Example

Syntax

Parameters

Callback Type Arguments

When an argument type is FFIType.callback ('k'), the JSCallback instance is automatically unwrapped to its .ptr:

Obtaining Pointers

Use ffi.getSymbolPtr(handle, name):

Async Version: AsyncCFunction

AsyncCFunction has the same signature as CFunction but returns Promise<number>, executing on a background thread without blocking the main thread.