From: David Fang <fang@csl.cornell.edu>
To: <guile-user@gnu.org>
Subject: modules and C
Date: Wed, 21 Mar 2007 17:57:25 -0500 (EST) [thread overview]
Message-ID: <20070321173609.K46895-100000@shannon.csl.cornell.edu> (raw)
Hi,
I'm having a bit of trouble using a symbol I defined in C from a
module:
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)
Backtrace:
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!
Fang
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
next reply other threads:[~2007-03-21 22:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-21 22:57 David Fang [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-03-22 0:17 modules and C dsmich
2007-03-23 7:01 Marco Maggi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070321173609.K46895-100000@shannon.csl.cornell.edu \
--to=fang@csl.cornell.edu \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).