> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arkffi.hmbill.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# FFIType

> Type constants for C function definitions

`FFIType` provides type constants used in function definitions.

## Constants

| Constant                                                 | Code | TS Type      | C Type                 |
| -------------------------------------------------------- | ---- | ------------ | ---------------------- |
| `FFIType.char` / `int8_t` / `i8`                         | `c`  | `number`     | `char` / `int8_t`      |
| `FFIType.uint8_t` / `u8`                                 | `i`  | `number`     | `uint8_t`              |
| `FFIType.int16_t` / `i16`                                | `i`  | `number`     | `int16_t`              |
| `FFIType.uint16_t` / `u16`                               | `i`  | `number`     | `uint16_t`             |
| `FFIType.int32` / `i32` / `int` / `uint32_t` / `u32`     | `i`  | `number`     | `int32_t`              |
| `FFIType.int64` / `i64` / `int64_t` / `uint64_t` / `u64` | `l`  | `number`     | `int64_t` / `uint64_t` |
| `FFIType.double` / `f64`                                 | `d`  | `number`     | `double`               |
| `FFIType.float` / `f32`                                  | `f`  | `number`     | `float`                |
| `FFIType.bool`                                           | `b`  | `number`     | `bool`                 |
| `FFIType.CString`                                        | `s`  | `string`     | `const char*`          |
| `FFIType.ptr` / `pointer` / `function` / `buffer`        | `p`  | `number`     | `void*`                |
| `FFIType.callback`                                       | `k`  | `JSCallback` | `int32_t (*)(int32_t)` |
| `FFIType.usize`                                          | `l`  | `number`     | `size_t` / `uintptr_t` |

## Usage

```typescript theme={null}
import { FFIType } from 'arkffi';

const def = {
  args: [FFIType.int32, FFIType.double, FFIType.CString],
  returns: FFIType.double,
};

// String literals are also accepted (shorthand):
// args: ['i', 'd', 's']
// returns: 'd'
```

## ARM64 Register Mapping

| C Type                         | TS Type  | Register        |
| ------------------------------ | -------- | --------------- |
| `int32_t`, `bool`, `char`      | `number` | x0-x7           |
| `int64_t`, `uint64_t`, `void*` | `number` | x0-x7           |
| `float`, `double`              | `number` | v0-v7           |
| `const char*`                  | `string` | x0-x7 (pointer) |
