syphilis has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

The script:
use Inline C => Config => CLEAN_AFTER_BUILD => 1, BUILD_NOISY => 1; use Inline C => <<'EOC'; SV * foo(FILE * stream) { return newSVuv(42); } EOC print foo(*STDOUT);
Running on perl 5.6 I get the following warning during compilation:
try_pl_0446.c: In function `XS_main_foo': try_pl_0446.c:28: warning: initialization from incompatible pointer ty +pe
Looking at the C file I see that line 28 is:
FILE * stream = IoIFP(sv_2io(ST(0)));
The same script, run under perl 5.8 produces no compiler warnings. The corresponding line in the C file is:
FILE * stream = PerlIO_findFILE(IoIFP(sv_2io(ST(0))));
(Note that in both instances the C file was autogenerated by ExtUtils::ParseXS version 2.17.)

Questions:
1) Is there anything I can do to remove that warning with perl 5.6 ?
2) Should I be perturbed by the warning issued with perl 5.6 ?

It's unlikely that the actual demo I've provided is going to suffer from the "incompatible pointer" ... but in the real world, foo() actually *does* something with the FILE* argument. So far, it all seems to work as intended ... but compiler warnings always worry me ...

Cheers,
Rob

Replies are listed 'Best First'.
Re: FILE* ... perl 5.6 ... backwards compatibility
by BrowserUk (Patriarch) on Dec 05, 2007 at 13:03 UTC
      As with perl 5.8, the presence (or absence) of the backslash seems to make no difference at all.

      (Note that, in any case, it won't have any effect on the actual warnings I quoted - as they occur during the compilation of the C code, long before any arguments actually get passed to foo.)

      I was curious to see what happened on linux with 5.6, but make didn't like the makefile that Configure created and I quickly lost interest in building perl 5.6 on my linux box.

      I'll assume the warnings are benign ... until evidence to the contrary presents itself.

      Cheers,
      Rob