► |  | FFI: PLT Scheme Foreign Interface

1 | Overview
2 | Loading Foreign Libraries
3 | C Types
4 | Pointer Functions
5 | Miscellaneous Support
6 | Derived Utilities
7 | Unexported Primitive Functions
8 | Macros for Unsafety
| Index

▼ | 3 | C Types

3.1 | Type Constructors
3.2 | Numeric Types
3.3 | Other Atomic Types
3.4 | String Types
3.5 | Pointer Types
3.6 | Function Types
3.7 | C Struct Types
3.8 | Enumerations and Masks

On this page:

_ pointer
_ gcpointer
_ scheme
_ fpointer
_ or-null
_ gcable

top← prev up next →

#### 3.5`` Pointer Types

_pointer : ctype?

Corresponds to Scheme “C pointer” objects. These pointers can have an arbitrary Scheme object attached as a type tag. The tag is ignored by built-in functionality; it is intended to be used by interfaces. See Tagged C Pointer Types for creating pointer types that use these tags for safety. A #f value is converted to NULL and vice-versa.

The address referenced by a _pointer value must not refer to memory managed by the garbage collector (unless the address corresponds to a value that supports interior pointers and that is otherwise referenced to preserve the value from garbage collection). The reference is not traced or updated by the garbage collector.

_gcpointer : ctype?

Like _pointer, but for a value that can refer to memory managed by the garbage collector.

Although a _gcpointer can reference to memory that is not managed by the garbage collector, beware of using an address that might eventually become managed by the garbage collector. For example, if a reference is created by malloc with 'raw and released by free, then the free may allow the memory formerly occupied by the reference to be used later by the garbage collector.

_scheme : ctype?

This type can be used with any Scheme object; it corresponds to the Scheme_Object* type of PLT Scheme’s C API (see Inside: PLT Scheme C API). It is useful only for libraries that are aware of PLT Scheme’s C API.

_fpointer : ctype?

Similar to _pointer, except that when an _fpointer is extracted from a pointer produced by ffi-obj-ref, then a level of indirection is skipped. A level of indirection is similarly skipped when extracting a pointer via get-ffi-obj. Like _pointer, _fpointer treats #f as NULL and vice-versa.

A type generated by _cprocedure builds on _fpointer, and normally _cprocedure should be used instead of _fpointer.

(_or-null ctype) → ctype?
ctype : ctype?

Creates a type that is like ctype, but #f is converted to NULL and vice-versa. The given ctype must have the same C representation as _pointer, _gcpointer, or _fpointer.

(_gcable ctype) → ctype?
ctype : ctype?

Creates a type that is like ctype, but whose base representation is like _gcpointer instead of _pointer. The given ctype must have a base representation like _pointer or _gcpointer (and in the later case, the result is the ctype).
top← prev up next →