As an argument, the input Scheme character is cast to C char or unsigned char, resulting in an 8-bit value. A Scheme character with an integer value outside 0-127 (signed) or 0-255 (unsigned) will be silently truncated to fit; in other words, don't feed it UTF-8 data.

As a return type, accepts any valid UTF-8 codepoint; the return type is treated as a C int, and converted to a Scheme character.

An 8-bit integer value in range -128 - 127 (byte) or 0 - 255 (unsigned byte). Values are cast to and from C char or unsigned char type, so values outside this 8-bit range will be unceremoniously truncated.

[type]short[type]unsigned-short

A short integer number in 16-bit range. Maps to C short or unsigned short.

[type]int[type]unsigned-int[type]int32[type]unsigned-int32

An integer number in fixnum range (-1073741824 to 1073741823, i.e. 31 bit signed). unsigned-int further restricts this range to 30 bit unsigned (0 to 1073741823). int maps to C type int and int32 maps to int32_t.

As an argument type, these expect a fixnum value, and as a return type they return a fixnum. Values outside the ranges prescribed above are silently truncated; you should use e.g. integer if you need the full 32-bit range. Note: int32 is not currently allowed as argument type.

Notes for 64-bit architectures:

C's int is 32 bits on most 64-bit systems (LP64), so int and int32 are functionally (if not semantically) equivalent.

The fixnum type is larger than 32 bits and consequently the entire signed or unsigned 32-bit range is available for this type on 64-bit systems. However, for compatibility with 32-bit systems it is probably unwise to rely on this. If you need a 32-bit range, you should use (unsigned) integer or integer32.

A fixnum or integral flonum, mapping to int or int32_t or their unsigned variants. When outside of fixnum range the value will overflow into a flonum.

C's int is 32 bits on most 64-bit systems (LP64), so integer and integer32 are functionally (if not semantically) equivalent.

[type]integer64[type]unsigned-integer64

A fixnum or integral flonum, mapping to int64_t or uint64_t. When outside of fixnum range the value will overflow into a flonum.

On a 32-bit system, the effective precision of this type is 52 bits plus the sign bit, as it is stored in a double flonum. (In other words, numbers between 2^52 and 2^64-1 can be represented but there are gaps in the sequence; the same goes for their negative counterparts.) On a 64-bit system the range is 62 bits plus the sign bit, the maximum range of a fixnum. (Numbers between 2^62 and 2^64-1 have gaps.)

unsigned-integer64 is not valid as a return type until Chicken 4.6.4.

[type]long[type]unsigned-long

Either a fixnum or a flonum in the range of an (unsigned) machine long. Similar to integer32 on 32-bit systems or integer64 on 64-bit.

A floating-point number. If an exact integer is passed as an argument, then it is automatically converted to a float.

[type]number

A floating-point number. Similar to double, but when used as a result type, then either an exact integer or a floating-point number is returned, depending on whether the result fits into an exact integer or not.

A zero-terminated C string. The argument value #f is allowed and is passed as a NULL pointer; similarly, a NULL pointer is returned as #f. Note that the string contents are copied into (automatically managed) temporary storage with a zero byte appended when passed as an argument. Also, a return value of this type is copied into garbage collected memory using strcpy(3).

For the nonnull- variant, passing #f will raise an exception, and returning a NULL pointer will result in undefined behavior (e.g. a segfault).

[type]c-string*[type]nonnull-c-string*

Similar to c-string and nonnull-c-string, but if used as a result type, the pointer returned by the foreign code will be freed (using the C library's free(3)) after copying. This type specifier is not valid as a result type for callbacks defined with define-external.

Same as c-string, nonnull-c-string, etc. but mapping to C's unsigned char * type.

[type]c-string-list[type]c-string-list*

Takes a pointer to an array of C strings terminated by a NULL pointer and returns a list of strings. The starred version c-string-list* also releases the storage of each string and the pointer array afterward using free(1).

Only valid as a result type, and can only be used with non-callback functions.

[type]symbol

A symbol, which will be passed to foreign code as a zero-terminated string.

When declared as the result of foreign code, the result should be a string and a symbol with the same name will be interned in the symbol table (and returned to the caller). Attempting to return a NULL string will raise an exception.

An operating-system pointer or a locative. c-pointer is untyped, whereas (c-pointer TYPE) points to an object of foreign type TYPE.

The value #f is allowed and is passed to C as a NULL pointer; similarly, NULL is returned as #f. For the two nonnull- variants, passing #f will raise an exception, and returning NULL will result in a null pointer object.

(Note: It is still possible to deliberately pass a null pointer through a nonnull-c-pointer by manually creating a null pointer object, e.g. via (address->pointer 0).)

[type]pointer-vector[type]nonnull-pointer-vector

A vector of foreign pointer objects; see Pointer vectors. Permitted only as an argument type, not as return type. This type was introduced in Chicken 4.6.3.

A pointer vector contains a C array of void pointers, and the argument is passed as a void ** pointer to these contents. Just as for bytevector types, you must somehow communicate the length of this array to the callee; there is no sentinel node or NULL terminator.

#f is allowed and passed as a NULL pointer. For the nonnull- variant, passing a #f value will raise an exception.

[type](ref TYPE)

A C++ reference type. Reference types are handled the same way as pointers inside Scheme code.

[type](function RESULTTYPE (ARGUMENTTYPE1 ... [...]) [CALLCONV])

A function pointer. CALLCONV specifies an optional calling convention and should be a string. The meaning of this string is entirely platform dependent. The value #f is also allowed and is passed as a NULL pointer.

An arbitrary, raw Scheme data object (immediate or non-immediate). A scheme-object is passed or returned as a C_word, the internal Chicken type for objects. Typically, this consists of an object header and tag bits. It is up to you to build or take apart such objects using the core library routines in chicken.h and runtime.c.

scheme-pointer is typically used to get a pointer to the raw byte content of strings and blobs. But if you pass in a SRFI-4 vector, you will get a pointer to a blob object header (not the blob's contents), which is almost certainly wrong. Instead, convert to a blob beforehand, or use a SRFI-4 specific type.