Does the interpreter support FFI ?
If not, then how can I "embed" custom FFI definitions into gsi so that they're available in REPL??
shen@ubuntu:~/gambc-v4_6_7-devel$ head test.scm (c-declare "#include "SDL.h"")
;;; SDL Constants ;;; (define sdl-init-timer #x00000001) (define sdl-init-audio #x00000010) (define sdl-init-video #x00000020) (define sdl-init-cdrom #x00000100) (define sdl-init-joystick #x00000200) (define sdl-init-noparachute #x00100000) (define sdl-init-eventthread #x01000000) shen@ubuntu:~/gambc-v4_6_7-devel$ gsi test.scm *** ERROR IN "test.scm"@1.1 -- Interpreter does not support ##c-declare
Afficher les réponses par date
On 2013-04-16, at 3:06 PM, Zhen Shen zhenshen10@outlook.com wrote:
Does the interpreter support FFI ?
The interpreter doesn't support the Gambit FFI (currently). One workflow that works well is to put the core FFI code in a .scm file, compile it to a .o1, and then "load" it at runtime (or put it in the gambcext file or gambcini.scm file).
If not, then how can I "embed" custom FFI definitions into gsi so that they're available in REPL??
shen@ubuntu:~/gambc-v4_6_7-devel$ head test.scm (c-declare "#include "SDL.h"")
;;; SDL Constants ;;; (define sdl-init-timer #x00000001) (define sdl-init-audio #x00000010) (define sdl-init-video #x00000020) (define sdl-init-cdrom #x00000100) (define sdl-init-joystick #x00000200) (define sdl-init-noparachute #x00100000) (define sdl-init-eventthread #x01000000) shen@ubuntu:~/gambc-v4_6_7-devel$ gsi test.scm *** ERROR IN "test.scm"@1.1 -- Interpreter does not support ##c-declare
Either you do as I suggest above, or you create your own version of gsi by linking your extensions. For example (using MinGW on Windows):
% cd gsi % echo "(define (hi) (pp 'hello))" > _extensions.scm % ../gsc/gsc -:=.. -link -l _gambcgsi _extensions.scm _gsi.scm % gcc -o mygsi -I../include _extensions.c _gsi.c _gsi_.c ../lib/libgambc.a libgambcgsi.a -lws2_32 % ./mygsi Gambit v4.6.7
(hi)
hello
Marc