[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] heap size or macro problem
From: |
Rick Taube |
Subject: |
Re: [Chicken-users] heap size or macro problem |
Date: |
Mon, 5 Nov 2007 06:57:37 -0600 |
I'm not sure yet that you do anything wrong. So this is an application
that embeds compiled Scheme code into a C/C++ app, right?
yes this is correct. we are trying to embed Chicken in our JUCE GUI
app for music.
Do you run CHICKEN_run() once and does the Scheme code do a
"(return-to host)"? In this situation, you don't need the "safe"
versions
of "foreign-lambda[*]" (I was refering to those, when I mentioned
"safe", i.e. "foreign-safe-lambda[*]").
yes and yes. (return-to-host) is the last line of our
ChickenBridge.scm file that we compiled to C++ and then compile/link
with our program:
csc -c++ -embedded -t ChickenBridge.scm
Then, in our C++ app the scheduler's "init" method starts up Chicken
like this, which includes chicken_run:
bool SchemeThread::init() {
int res;
C_word r;
char buffer[8192];
String text = T("Chicken Scheme");
// init chicken...
res = CHICKEN_initialize(0, 0, 0, (void*)C_grace_toplevel);
if (res==0) {
console->printError(T(">>> Error: Chicken failed to initialize.
\n"));
return false;
}
// run chicken...
res = CHICKEN_run(NULL);
if (res==0) {
console->printError(T(">>> Error: Chicken failed to initialize.
\n"));
return false;
}
// print chicken version info to Console Window:
res = CHICKEN_eval_string_to_string( (char*)"(chicken-version)",
buffer, 8192);
if (res>0)
text = text + T(", version ") + String(buffer).unquoted();
text += T("\n(c) 2000-2007 Felix L. Winkelmann\n");
console->printMessage(text);
bzero(buffer, 8192);
if (res==0) {
console->printError(T(">>> Error: Chicken failed to initialize.
\n"));
return false;
}
CHICKEN_eval_string("(require-extension srfi-18)", &r);
CHICKEN_eval_string("(require-extension srfi-1)", &r);
..}
Anyway, it's not trivial to get all this right, and the error messages
are often misleading.
it sure isnt. we are *hoping* to call chicken funcs in realtime for
music, our initial rough tests last week were showing that the GC
doesnt really get in the way even with modest amounts of garbage
being generated on callbacks happening every 50ms. but we wanted to
get the error protection stuff in place so we could test with a
"real" situation.
thanks!
--rick