[plt-scheme] embedding with 3m
Good.
I define my Scheme_Env *e to be a static variable because
I put this part of my program in a init() function. You
don't have to do the same, as you define it in main().
Cheers,
Chongkai
----- Original Message -----
From: "dave" <dave at pawfal.org>
To: "Chongkai Zhu" <czhu at cs.utah.edu>
Cc: <plt-scheme at list.cs.brown.edu>
Sent: Saturday, January 27, 2007 12:42 PM
Subject: Re: [plt-scheme] embedding with 3m
> On Sat, 2007-01-27 at 08:10 -0700, Chongkai Zhu wrote:
>> Hope it helps.
>
> It did - and I understand a little more about how it works now, thanks!
> For the record, this is the fixed version of that test:
>
> // g++ mz.cpp -o mz -L/usr/local/lib -I/usr/local/include/plt
> -lmzscheme3m -ldl
>
> #define MZ_PRECISE_GC
> #include <scheme.h>
>
> void interpret(Scheme_Env *e, char *code)
> {
> MZ_GC_DECL_REG(0);
> mz_jmp_buf * volatile save, fresh;
> save = scheme_current_thread->error_buf;
> scheme_current_thread->error_buf = &fresh;
>
> if (scheme_setjmp(scheme_error_buf))
> {
> scheme_current_thread->error_buf = save;
> exit(-1);
> }
> else
> {
> scheme_eval_string_all(code, e, 1);
> scheme_current_thread->error_buf = save;
> }
> }
>
> int main(int argc, char *argv[])
> {
> void *stack_start;
> stack_start = (void *)&stack_start;
>
> static Scheme_Env *e = NULL;
> #ifdef MZ_PRECISE_GC
> MZ_GC_DECL_REG(0);
> GC_init_type_tags(_scheme_last_type_, scheme_pair_type,
> scheme_weak_box_type, scheme_ephemeron_type, scheme_rt_weak_array);
> scheme_set_stack_base( &__gc_var_stack__, 1);
> #else
> scheme_set_stack_base( NULL, 1);
> #endif
>
> MZ_REGISTER_STATIC(e);
> e = scheme_basic_env();
> scheme_set_can_break(1);
>
> while(1)
> {
> interpret(e,"(display \"hello\")(newline)");
> }
>
> return 0;
> }
>
>
>
>