The following document assumes the reader has a knowledge of writing module extensions for Perl, and is going to attempt to write one for Perl for Win32. Writing Win32 Perl extensions is still a little tricky. See the source for the Extensions for examples on how this is done.
Here is a quick overview of the steps used to write module extensions.
In order to make extensions build with the current build of Perl for Win32, a few changes must be made to the C++ file generated by xsubpp. This is unfortunate, and will not be a permanent feature of Perl for Win32. Due to the way the perl300.dll was implemented, functions in the C++ file for the extensions that are not defined as XS(funcname) will cause compilation errors when they attempt to use any perl internal functions (eg: SvIV, etc). The way to fix this problem is to add 'CPerl* pPerl' as an argument to this function.
Eg:
// note the use of the pPerl here.
int constant(CPerl* pPerl, int arg)
{
if(arg == 0)
{
printf("zero entered\n");
return(0);
}
else
{
printf("a non-zero integer was entered\n");
return(1);
}
}
XS(MyPerlFunc)
{
dXSARGS;
int RETVAL;
int arg;
if(items < 1)
{
croak("usage: MyPerlFunc($value)\n");
}
arg = (int)SvIV(ST(0));
// note pPerl is passed to subroutine here.
RETVAL = constant(pPerl, arg);
XSRETURN(RETVAL);
}