Hello all,

When I try to feed this prototype

   void register_callback (SV *callback);

to h2xs, I get this error:

   [ ... ]
   Scanning /home/jw/mymod/mymod.h for functions...
   Expecting parenth after identifier in `SV *callback'
   after `SV ' at /usr/lib/perl5/site_perl/5.8.7/C/Scan.pm line 797.
   make: *** [xs] Error 255

Obviously, the reason is that the SV datatype is not defined.  So I
include perl.h to make this definition available:

   # include <perl.h>
   void register_callback (SV *callback);

Now h2xs runs almost forever, and reports the same error for some
system files:

   Expecting parenth after identifier in `fd_set *__restrict __readfds'
   after `fd_set ' at /usr/lib/perl5/site_perl/5.8.7/C/Scan.pm line 797.

So I remove the #include and add a fake typedef just to make h2xs happy:

   # ifdef FOR_H2XS_ONLY
   typedef void SV;
   # endif
   void register_callback (SV *callback);

With this, h2xs happily produces exactly the desired output.  But now
I get a compile error because this typedef conflicts with the original
typedef in perl.h

So I need some kludge to make this fake typedef visible _only_ to h2xs
but not to the compiler.  The closest I could find is

   h2xs [ ... ] -F -DFOR_H2XS_ONLY [ ... ]

But unfortunately, h2xs adds this to Makefile.PL too, so the compiler
sees the same definition as h2xs:

   [ ... ]
   cc -c [ ... ] -DFOR_H2XS_ONLY [ ... ] Mymod.c
   In file included from Mymod.xs:7:
   /home/jw/mymod/mymod.h:12: error: conflicting types for ‘SV’
   /usr/lib/perl5/5.8.7/i586-linux-thread-multi/CORE/perl.h:2024: error: 
previous declaration of ‘SV’ was here

Anybody have any idea how to properly make h2xs parse "SV *foo" arguments?

Reply via email to