Struct
class Struct Import
Source: use ffi::types::{Struct}; compiler/src/builtin_docs/ffi/types.hy FFI tag for a C struct passed or returned by value.
Not written directly: name an extern struct type in declare instead,
and the compiler uses this tag with that struct’s layout. A returned
struct becomes a record whose fields are read with .name.
Examples#
use ffi::{dload, declare, invoke};
use ffi::types::{Int32};
extern struct Point {
x: int32,
y: int32,
};
let make_id = declare(lib, "make_point", (Int32, Int32), Point)?;
let p = invoke(lib, make_id, (3, 4))?;
let sum = p.x + p.y; // 7
See also#
Int: 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.Int8: FFI tag for an 8-bit signed integer (int8_t), passed from and returned asint.Int16: FFI tag for a 16-bit signed integer (int16_t), passed from and returned asint.Int32: FFI tag for a 32-bit signed integer (int32_t), passed from and returned asint.