cfunction
cfunction(function::Function, ReturnType::Type, (ArgumentTypes...))
Generate C-callable function pointer from Julia function. Type annotation of the return value in the callback function is a must for situations where Julia cannot infer the return type automatically.
For example:
function foo()
# body
retval::Float64
end
bar = cfunction(foo, Float64, ())
Examples
julia> function foo()
# body
retval::Float64
end
julia> bar = cfunction(foo, Float64, ())
Ptr{Nothing} @0x0000000000000000
In this example, the cfunction
is used to generate a C-callable function pointer bar
from the Julia function foo
. The return type of foo
is specified as Float64
using type annotation.
Note: The actual memory address (@0x0000000000000000
) shown here may vary.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.