From: Viktor Pavlenko <vvp@rogers.com>
Subject: Re: how to access subr from scm module?
Date: Mon, 18 Nov 2002 20:50:43 -0500 [thread overview]
Message-ID: <15833.39155.182879.655339@shmyh.ua> (raw)
In-Reply-To: <15832.2016.640715.722210@shmyh.ua>
>>>>> "VP" == Viktor Pavlenko <vvp@rogers.com> writes:
VP> I would prefer making a SCM module of my C procedures [...]
... and this is how to do it (I'm posting this in hope it may save
someone's time).
Regards
Viktor
------------------------------------------------------------------>8
#include <libguile.h>
SCM my_proc()
{
return scm_makfrom0str( "testing" );
}
void
init( void* )
{
SCM proc_scm = scm_c_define_gsubr( "*my-proc*", 0, 0, 0, my_proc );
scm_c_export( "*my-proc*", 0 );
}
void
inner_main( void*, int argc, char **argv )
{
scm_c_define_module( "test-module", init, 0 );
/* using it from C */
scm_c_use_module( "test-module" );
scm_c_lookup( "*my-proc*" ); /* OK */
/* to use it from a scheme module loaded from C code:
(use-modules (test-module))
(*my-proc*)
*/
}
int
main( int argc, char** argv )
{
scm_boot_guile(argc, argv, inner_main, 0);
return 0;
}
------------------------------------------------------------------>8
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
prev parent reply other threads:[~2002-11-19 1:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-17 21:19 how to access subr from scm module? Viktor Pavlenko
2002-11-19 1:50 ` Viktor Pavlenko [this message]
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=15833.39155.182879.655339@shmyh.ua \
--to=vvp@rogers.com \
/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).