# Primitive Types

## Overview

Primitive types have a single value, these include characters, numbers, and pointers. They are all symbols in the keyword package.

- `:char` - Signed 8-bits. A dereferenced :char pointer returns an character.

- `:unsigned-char` - Unsigned 8-bits. A dereferenced :unsigned-char pointer returns an character.

- `:byte` - Signed 8-bits. A dereferenced :byte pointer returns an integer.

- `:unsigned-byte` - Unsigned 8-bits. A dereferenced :unsigned-byte pointer returns an integer.

- `:short` - Signed 16-bits.

- `:unsigned-short` - Unsigned 16-bits.

- `:int` - Signed 32-bits.

- `:unsigned-int` - Unsigned 32-bits.

- `:long` - Signed 32 or 64 bit integer, depending upon the platform.

- `:unsigned-long` - Unsigned 32 or 64 bit integer, depending upon the platform.

- `:long-long` - Signed 64 bits integer for implementations that support this. If implementation does not support this, `'uffi:no-long-long` is pushed on the cl:*features* list.

- `:unsigned-long-long` - Unsigned 64 bits integer for implementations that support this. If implementation does not support this, `'uffi:no-long-long` is pushed on the cl:*features* list.

- `:float` - 32-bit floating point.

- `:double` - 64-bit floating point.

- `:cstring` - A &null; terminated string used for passing and returning characters strings with a &c; function.

- `:void` - The absence of a value. Used to indicate that a function does not return a value.

- `:pointer-void` - Points to a generic object.

- `*` - Used to declare a pointer to an object

def-constant

Binds a symbol to a constant.

Macro

## Syntax

    	def-constant name value &key export

### Arguments and Values

`name`

- A symbol that will be bound to the value.

`value`

- An evaluated form that is bound the the name.

`export`

- When &t;, the name is exported from the current package. The default is &nil;

### Description

This is a thin wrapper around `defconstant`. It evaluates at compile-time and optionally exports the symbol from the package.

### Examples

    (def-constant pi2 (* 2 pi))
    (def-constant exported-pi2 (* 2 pi) :export t)

### Side Effects

Creates a new special variable..

### Affected by

None.

### Exceptional Situations

None.

def-foreign-type

Defines a new foreign type.

Macro

### Syntax

    	def-foreign-type name type

### Arguments and Values

`name`

- A symbol naming the new foreign type.

`value`

- A form that is not evaluated that defines the new foreign type.

### Description

Defines a new foreign type.

### Examples

    (def-foreign-type my-generic-pointer :pointer-void)
    (def-foreign-type a-double-float :double-float)
    (def-foreign-type char-ptr (* :char))

### Side Effects

Defines a new foreign type.

### Affected by

None.

### Exceptional Situations

None.

null-char-p

Tests a character for &null; value.

Macro

### Syntax

    	null-char-p char => is-null

### Arguments and Values

`char`

- A character or integer.

`is-null`

- A boolean flag indicating if char is a &null; value.

### Description

A predicate testing if a character or integer is &null;. This abstracts the difference in implementations where some return a `character` and some return a `integer` whence dereferencing a `C` character pointer.

### Examples

    (def-array-pointer ca :unsigned-char)
    (let ((fs (convert-to-foreign-string "ab")))
          (values (null-char-p (deref-array fs 'ca 0))
          (null-char-p (deref-array fs 'ca 2))))
    => &nil;
       &t;

### Side Effects

None.

### Affected by

None.

### Exceptional Situations

None.