Skip to content

Instantly share code, notes, and snippets.

Created March 23, 2014 15:07
What would you like to do?
Example of calling Guile scheme code from C. The scheme code can be modified without recompiling the C code.
(define simple-func
(lambda ()
(display "Script called, now I can change this") (newline)))
(define quick-test
(lambda ()
(display "Adding another function, can modify without recompilation")
(define adding-without-recompilation
(lambda ()
(display "Called this, without recompiling the C code") (newline)))
* Compile using:
* gcc testguile.c \
* -I/usr/local/Cellar/guile/1.8.8/include \
* -D_THREAD_SAFE -L/usr/local/Cellar/guile/1.8.8/lib -lguile -lltdl -lgmp -lm -lltdl -o testguile
#include <stdio.h>
#include <libguile.h>
int main(int argc, char** argv) {
SCM func, func2;
func = scm_variable_ref(scm_c_lookup("simple-func"));
func2 = scm_variable_ref(scm_c_lookup("quick-test"));
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment