guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exporting first class global variables from c...


From: Matthias Koeppe
Subject: Re: exporting first class global variables from c...
Date: Fri, 09 Aug 2002 13:39:44 +0200
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1.80 (sparc-sun-solaris2.7)

Matthew Whitworth <address@hidden> writes:

> I've just started experimenting with Guile (and Scheme for that matter)
> and have worked through and the tortoise tutorial.  Now I would like
> to export global variable from my C program into Guile where it can be
> modified by set!, but I can't figure out how to do it or find any
> documentation.
>
> SWIG seems to accomplish this by wrapping the C variable in a dual-purpose
> getter/setter function, but the semantics seem a liitle kludgy (and
> I've had some trouble getting things to work as I expected).

If you invoke recent SWIG versions (1.3.x) with the "-emit-setters"
option, SWIG creates "procedures-with-setters" for C variables.  This
means that you can use the syntax (VARIABLE) to get the value and
(set! (VARIABLE) VALUE) to set it.

If you don't use SWIG, you can accomplish the same using the
scm_make_procedure_with_setter() C function.

Regards,

-- 
Matthias Köppe -- http://www.math.uni-magdeburg.de/~mkoeppe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]