Passing pointers to C functions
Factor handbook » C library interface » Passing data between Factor and C

Prev:C type specifiers
Next:Manual memory management


The following Factor objects may be passed to C function parameters with pointer types:
Instances of alien.
Instances of f; this is interpreted as a null pointer.
Instances of byte-array; the C function receives a pointer to the first element of the array.
Any data type which defines a method on >c-ptr. This includes Struct classes and Specialized arrays.

The class of primitive C pointer types:
c-ptr


A generic word for converting any object to a C pointer; user-defined types may add methods to this generic word:
>c-ptr ( obj -- c-ptr )


More about the alien type:
Alien addresses

Warning
The Factor garbage collector can move byte arrays around, and code passing byte arrays, or objects backed by byte arrays, must obey important guidelines. See Byte arrays and the garbage collector.