Ruby windows extension printf/scanf crash, but fgetc/fputc o

Greetings,

I have a ruby extension I wrote a ruby extension that runs perfectly
well on my OS X Tiger Box, but when I try to compile it for windows
via
http://www.koontzfamily.org/david/blog/?p=230

I run into some issues. One of which is that when I have a FILE *
that I got from this macro I wrote:
#define GRAB_FILE(a) (RFILE(a)->fptr->f)
I run into issues with fscanf and fprintf. For fscanf, there is a
windows message dialog saying
“The exception unknown software exception (0xc0000008) occurred in
the application at location 0x77fac57c” … click ok to terminate,
cancel to debug (I know, not entirely useful, jsut explaining exactly
what happened).

For fprintf, I get
bouts_intervals.rb:250: [BUG] Segmentation fault
ruby 1.8.4 (2006-04-14) [i386-mswin32]

ie just a seg-fault.

The offending fprintf code (this is the unexpanded macro version):
fprintf(out,
“/* Automatically Generated C Program to run Bouts List Analysis.
*/” “\n”
“\n”
#include "%s"” “\n”
“\n”
“\n”,
name##_report);
fputc works perfectly well.

the offending fscanf code is:
long reading = 0;

while (1) {
switch (fscanf(channel, “%ld”, &reading)) {
BUT note that fgetc works perfectly well on channel, and returns the
data in the file accurately (note that fscanf has also been used

The ruby headers do seem to replace fputc and fgetc – but why not
fprintf / fscanf? Is there anything I can do to fix these?

~Matthew Maycock