[Top][All Lists]

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

modules and C

From: David Fang
Subject: modules and C
Date: Wed, 21 Mar 2007 17:57:25 -0500 (EST)

        I'm having a bit of trouble using a symbol I defined in C from a

        In a .cc file, I've defined some_C_function(), and exposed it to
guile via scm_c_define_gsubr("some-C-function", ...), which is called upon
initialization as part of an inner_main() passed to scm_shell().  The
program loads up fine, and I'm able to interactively call
(some-C-function) in the interpreter.
        In a .scm module file, I (define-module (foo bar)) and
(define-public (blah x) (some-C-function x)).
I run my program again (with a GUILE_LOAD_PATH to the new .scm),
guile> (use-modules (foo bar))
I see both 'some-C-function' and 'blah' are available procedures, but as
soon as I call (blah ...), I get "Unbound variable: some-C-function"

guile> blah
#<procedure blah (x)>
guile> some-C-function
#<primitive-procedure some-C-function>

guile> (blah 1)

In current input:
   5: 0* [blah <raw-chpsim-trace-stream>]
In ../../../../src/scm/foo/bar.scm:
  48: 1  (some-C-function x)

which indicates that my C-wrapped functions aren't visible to the newly
defined module, even through they are present in the interpreter's
environment.  What do I need to do to export my scm_c_define_gsubr'd
functions to the module?  Must I wrap them into another module in C, and
use-module it?  (Would I expect the same problem with mixing
load-extensions with modules?)

I've been reading the manuals and info on the module's sections and didn't
find a satisfactory answer.  (Is this a 'quirk?')  What basic concept(s)
am I missing here?  Thanks in advance!


reply via email to

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