next up previous contents
Next: Profiling Up: Foreign function interface (FFI) Previous: Compile-time constants   Contents

Example

The example in the examples/ffi directory demonstrates the use of _ffi and _prim declarations. The Makefile demonstrates how to call MLton to include and link with the appropriate files. Running make should produce an executable, ffi, which should output success when run. You should also read Section 4.1 to familiarize yourself with the MLton options governing include files and linking (-include, -I, -l, and -L).

% mlton -stop o ffi.c
% mlton -I. -include ffi.h main.sml ffi.o
% main
13
success