newcclosure Synchronous
Wrap a callback in a C closure while forwarding its arguments and results. This is useful when an API requires a C closure but your behavior is written in Luau.
Luau
newcclosure(callback: Function, name: string?) -> FunctionParameters
| Parameter | Type | Description |
|---|---|---|
callback | Function | The function the wrapper will call. |
name | string? | Optional debug name for the wrapper. |
Returns
FunctionA new C closure. Its callback may yield when the surrounding call allows yielding.
Example
Luau
local wrapped = newcclosure(function(a, b)
return a + b
end, "add")
print(iscclosure(wrapped), wrapped(2, 3)) -- true, 5