Ptr
class Ptr Import
Source: use ffi::types::{Ptr}; compiler/src/builtin_docs/ffi/types.hy FFI tag for a raw pointer (void *), returned as an int address.
A Vec<T>, [T; N] or tuple type written in a declare signature also
means Ptr.
As an argument, an int is passed as the address itself, and a non-empty
array or tuple of int is passed as a pointer to a temporary
int64_t[] copy whose changes are copied back after the call. Keep a
value C retains alive with gc::root.
Examples#
use ffi::{dload, declare, invoke};
use ffi::types::{Int, Ptr};
let lib = dload("sum")?;
// int64_t sum_array(const int64_t *xs, int64_t n)
let id = declare(lib, "sum_array", (Ptr, Int), Int)?;
let n = invoke(lib, id, ([1, 2, 3, 4, 5], 5))?; // 15
See also#
intVecgc::rootInt: FFI tag for a 64-bit signed integer (int64_t), passed from and returned asint.Float: FFI tag for a 64-bit float (double), passed from and returned asfloat.String: FFI tag for a NUL-terminated C string (const char *), passed from and returned asstring.Void: FFI tag for no value (void), valid only as a return type.Bool: FFI tag for a Cbool(one byte,0or1), passed from and returned asbool.