Hi, I am using Swig to create a wrapper between C and Perl communication. It generates run time error when I try to access file pointer in C opened in Perl. The message shown at run time is
"The instruction at "0x77f88216" referenced memory at "0x00000000". The memory could not be written". Below are the corresponding files I am using to attain communication: 1. Interface file cprog.i used in swig to create a wrapper file %module cprog %typemap(perl5,in) FILE * { $target = IoIFP(sv_2io($source));\ } int testing(FILE* fp); Swig command I use to create wrapper cprog_wrap.c is swig -perl -exportall cprog.i 2. C file "cprog.c" to communicate with perl #include <stdio.h> int testing(FILE* fp) { if(fp) fputs("hello", fp); else return 0; } 3. Perl file "perl1.pl" I use to communicate with C file "cprog.c" use cprog; open(OUT, ">-"); $ret = testing(*OUT); print $ret; Following gives the compilling and linking I use to create the dll "cprog.dll" cl.exe -I "c:\Program Files\Microsoft Visual Studio .NET\Vc7\include" -Ic:\Perl\lib\CORE -I "c:\Program Files\Microsoft Visual Studio NET\Vc7\PlatformSDK\Include" -c cprog.c cprog_wrap.c -nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX link.exe -dll -nologo -nodefaultlib -opt:ref,icf -libpath:"C:\Perl\lib\CORE" -machine:x86 /out:cprog.dll cprog.obj cprog_wrap.obj perl58.lib /LIBPATH:"c:\Program Files\Microsoft Visual Studio .NET\Vc7\lib" msvcrt.lib kernel32.lib Actual run time problem occurs when I try to use "fputs()" in C using file pointer created in Perl. Can anyone explain me soon wht's the problem and how should i rectify it? Regards, Karthik.