Skip to content

Document how to use the FFI

Thomas Koopman requested to merge thomas/sac2c:help-message into index-types
thomas@debian:~/repos/sac2c/build_p$ ./sac2c_p -h ffi

---------------------------------------------------------------------------
 SAC - Single Assignment C
---------------------------------------------------------------------------

Name:    sac2c
Version: 2.0.0-Tintigny-528-g5fdbd

FOREIGN FUNCTION INTERFACE (FFI) HELP:

        If you want implement a function in C, but for use from SaC, e.g.
                external double[n] foo(int m, double[n] x);
        you would use sac_int in the C-file, so
                void foo(sac_int m, SACARG x);
        In the C-file, you need to include <sacinterface.h> and compile with    sac2c_p -cc ccmod. You can pass additional C-flags with -Xc.
        For example, replace
                gcc -mfma kernel.c -o kernel.o
        with
                sac2c_p -cc ccmod -Xc -mfma kernel.c -o kernel.o
Edited by Thomas Koopman

Merge request reports