Update
Thanks to the comments by @selbie, the following modified program works (note that we obtain a second pointer to the array res and pass its address to FFI):
#include <stdio.h> #include <stdlib.h> #include <ffi.h> unsigned my_func(double a, double b, double *res) { res[0] = a + b; res[1] = a - b; return 0; } int main(int argc, char *argv[]) { ffi_cif cif; ffi_type *arg_types[3] = { &ffi_type_double, &ffi_type_double, &ffi_type_pointer }; ffi_type *rettype = &ffi_type_uint; if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, rettype, arg_types) != FFI_OK) { fprintf(stderr, "ffi_prep_cif is not successful\n"); exit(EXIT_FAILURE); } double a = 3.0; double b = 2.0; double res[2] = {99.0, 15.0}; double *p_res = res; void *arg_values[3] = { &a, &b, // res &p_res }; unsigned status; ffi_call(&cif, FFI_FN(my_func), &status, arg_values); printf("Function return status code %u\n", status); printf("Values in res array: \n"); printf("[0] = %f\n", res[0]); printf("[1] = %f\n", res[1]); return 0; }