[plt-scheme] Standard output from C extensions

From: Bruce Hauman (bhauman at cs.wcu.edu)
Date: Mon Feb 23 12:49:13 EST 2004

sajiimori wrote:

 > Hi everybody,
 >
 > First off I'd like to thank PLT for producing what is possibly the 
best free
 > software I've ever seen.  You've changed the way I think about 
open-source
 > software, and even programming in general.
 >
 > I'm making a MzScheme extension in C.  It doesn't use any scheme 
functions,
 > and I have a seperate .scm file that uses c-lambda to provide hooks, 
then I
 > compile them together to produce a DLL.  It's working ok, but standard
 > output (via the C library) only displays when I run MzScheme directly 
-- not
 > in DrScheme.
 >
 > Can I get standard output to appear in DrScheme's interactions window
 > (preferably without adding MzScheme-specific code to the C file)?
 >

This is how you can print to DrScheme or MzScheme

char * c_str = "hello";
Scheme_Object * sch_str;
Scheme_Object *curout =
   scheme_get_param(scheme_config, MZCONFIG_OUTPUT_PORT);
str =  scheme_make_string(c_str);
scheme_display(sch_str, curout);

You can abstract out the mzscheme specific code into a separate function 
so that you don't have to deal with it.

Bruce

P.S. I posted some mp3 playing code on comp.lang.scheme.


Posted on the users mailing list.