Hi,
I have an XS function that gets a FILE * back from a library function
that it calls and then tries to PerlIO_importFILE() that into a PerlIO
*. Just for completeness my code checks for the (presumably rather
unlikely) event that this could fail, and in this case it tidies up by
fclose()'ing the now-useless FILE *. Something like this:
FILE *fp;
PerlIO *pfp;
fp = my_library_fn();
if (fp != Null(FILE *)) {
pfp = PerlIO_importFILE(fp, mode);
if (pfp != Nullfp) {
# Good. Do some stuff...
}
else {
# Oh dear. Clean up...
fclose(fp);
# Return failure.
}
}
else {
# Oh dear.
# Return failure.
}
My problem is this: When I build this with a Perl that I built it all
works fine, but when I build it with ActivePerl I get the following two
warnings from the compiler:
warning C4047: 'function' : 'struct _PerlIO ** ' differs in levels of
indirection from 'struct _iobuf *'
warning C4024: 'Perl_PerlIO_close' : different types for formal and
actual parameter 2
The line numbers in the error messages refer to several lines before the
fclose() in the above code snippet, but if I comment out that fclose()
then it all works OK. Why does this happen?
The only difference between my own Perl build and ActivePerl is the
build options -- I'm using ActivePerl 5.8.0 Build 804, and my Perl is
built from those sources. Specifically, ActivePerl has MULTIPLICITY,
USE_ITHREADS, USE_LARGE_FILES, PERL_IMPLICIT_CONTEXT, PERL_IMPLICIT_SYS
and uses the system's malloc(), while my Perl disables all of these and
uses Perl's malloc().
I suspect the difference arises from the use/non-use of
PERL_IMPLICIT_SYS, but I can't pin it down.
Can anybody explain what is going on and how to resolve it?
BTW, my XS file specifies "#define PERLIO_NOT_STDIO 0" before including
the Perl headers, as described in "perlapio" manpage.
I'm working on Windows XP SP1 with MS VC/C++ 6 SP5.
Thanks
Steve Hay
- Re: How to use fclose() with ActivePerl Steve Hay
- Re: How to use fclose() with ActivePerl Nick Ing-Simmons
- Re: How to use fclose() with ActivePerl Steve Hay
- Re: How to use fclose() with ActivePerl Nick Ing-Simmons
- Re: How to use fclose() with ActivePerl Steve Hay
- Re: How to use fclose() with ActivePerl Steve Hay
- Re: How to use fclose() with ActivePerl Nick Ing-Simmons
