manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ] Foreign Types

The first impedance mismatch that one sees between C and Scheme is that in C, the storage locations (variables) are typed, but in Scheme types are associated with values, not variables. See section Values and Variables.

So when describing a C function or a C structure so that it can be accessed from Scheme, the data types of the parameters or fields must be passed explicitly.

These “C type values” may be constructed using the constants and procedures from the (system foreign) module, which may be loaded like this:

(use-modules (system foreign))

(system foreign) exports a number of values expressing the basic C types:

Scheme Variable: int8
Scheme Variable: uint8
Scheme Variable: uint16
Scheme Variable: int16
Scheme Variable: uint32
Scheme Variable: int32
Scheme Variable: uint64
Scheme Variable: int64
Scheme Variable: float
Scheme Variable: double

These values represent the C numeric types of the specified sizes and signednesses.

In addition there are some convenience bindings for indicating types of platform-dependent size:

Scheme Variable: int
Scheme Variable: unsigned-int
Scheme Variable: long
Scheme Variable: unsigned-long
Scheme Variable: size_t

Values exported by the (system foreign) module, representing C numeric types. For example, long may be equal? to int64 on a 64-bit platform.

Scheme Variable: void

The void type. It can be used as the first argument to pointer->procedure to wrap a C function that returns nothing.

In addition, the symbol * is used by convention to denote pointer types. Procedures detailed in the following sections, such as pointer->procedure, accept it as a type descriptor.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on February 3, 2012 using texi2html 5.0.

© 2000-2015
Individual documents may contain additional copyright information.