Skip to content

Instantly share code, notes, and snippets.

Red []
forth: context [
prog: [1 2 3 4 5 6 7 8 '+ '+ '* 150 '+ '* '+ '* '*]
registers: ['eax 'ebx 'ecx 'edx]
register-taint: [] ; registers we've touched in this set
register-goop: [] ; registers we need to pop to use
register-sets: 0
next-register: head registers

Binding Rust to C

This document is a work in progress, and is primarily concerned with getting Rust code able to talk with C code. What we cover here is writing 'bindings', we will cover 'wrapping' up the bindings and providing an elegant interface in the next document.

Extern blocks

The most basic building block of interfacing Rust with C is the extern block, which is necessary for telling Rust that the C functions you wish to use actually exist.

Example.