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

Windows Embedding Issues



The "Inside PLT MzScheme" document indicates that the garbage
collector needs to be configured (using GC_use_registered_statics=1)
to avoid collecting objects that it does not control.

Does this mean than any static variables contained in an
embedding program needs to be registered using
"scheme_register_static()" ?

E.g., for a program:

#include "scheme.h"

static int foo1;

int main(int argc, char *argv[])
{
  foo1 = 12345;

  Scheme_Env *e = scheme_basic_env();
  Scheme_Object *curout = scheme_get_param(scheme_config,
MZCONFIG_OUTPUT_PORT);
  int i;
  for (i = 1; i < argc; i++) {
    ++foo1;
    if (scheme_setjmp(scheme_error_buf)) {
      return -1; /* There was an error */
    } else {
      Scheme_Object *v = scheme_eval_string(argv[i], e);
      scheme_display(v, curout);
      scheme_display(scheme_make_character('\n'), curout);
    }
  }
  printf("Value = %ld", foo1);
  return 0;
}

Does foo1 need to be registered?  If so, it's going to be hard to
properly embed MzScheme in existing applications without running
through the entire code base to find the statics.

I suppose I could have an init routine that would just do something like:

scheme_register_static(foo1);
/ ... /
scheme_register_static(foo12345586869);

But this seems like a lot of typing!

Hopefully I'm just misunderstanding.  Perhaps you only mean actual Scheme
objects, and not all static variables.

Thanks,

-Brent