"Jan Dubois" ([email protected]) writes:
> I suspect that you'll need to attach some complete example project
> that exhibits the things you are talking about before somebody else
> will try to reproduce/understand it.
>
> Right now the barrier to helping you is quite high!
Okidoki.
Here is TestInSummertime.pm:
------------------------------------------------------------------------
package TestInSummertime;
use strict;
use Exporter;
use DynaLoader;
use vars qw(@ISA @EXPORT $VERSION);
$VERSION = '1.000';
@ISA = qw(Exporter DynaLoader);
bootstrap TestInSummertime;
@EXPORT = qw(arraytest hashtest);
1;
----------------------------------------------------------------------
Here is TestInSummertime.xs:
---------------------------------------------------------------------
#include <windows.h>
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
MODULE = TestInSummertime PACKAGE = TestInSummertime
PROTOTYPES: ENABLE
void
arraytest(arrayref)
SV * arrayref
CODE:
{
AV * av = (AV *) SvRV(arrayref);
SV ** svp = av_fetch(av, 0, 0);
SV * sv = *svp;
SvGETMAGIC(sv);
warn ("SvOK = %d\n", SvOK(sv));
warn ("SvIV = %d\n", SvIV(sv));
warn ("SvOK = %d\n", SvOK(sv));
}
void
hashtest(hashref)
SV * hashref
CODE:
{
HV * hv = (HV *) SvRV(hashref);
HE * he = hv_iternext(hv);
SV * sv = hv_iterval(hv, he);
SvGETMAGIC(sv);
warn ("SvOK = %d\n", SvOK(sv));
warn ("SvIV = %d\n", SvIV(sv));
warn ("SvOK = %d\n", SvOK(sv));
}
-------------------------------------------------------------------
And here is makefile.pl
-------------------------------------------------------------------
use strict;
use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'TestInSummertime',
'OBJECT' => 'TestInSummertime.obj',
'CCFLAGS' => '-MT',
'LIBS' => [":nosearch :nodefault delayimp.lib kernel32.lib " .
user32.lib ole32.lib oleaut32.lib uuid.lib " .
libcmt.lib"],
'VERSION_FROM' => 'TestInSummertime.pm',
'XS' => { 'TestInSummertime.xs' => 'TestInSummertime.cpp' }
);
sub MY::xs_c {
'
.xs.cpp:
$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG)
$(XSUBPPARGS) $*.xs >xstmp.c && $(MV) xstmp.c $*.cpp
';
}
--------------------------------------------------------------------
As posted, the project works, but if I comment out the #include of
windows.h, I get tons of errors, starting with:
f:\perl\as1007-x86\lib\core\win32.h(341) : error C2061: syntax error :
identifier 'Stat_t'
f:\perl\as1007-x86\lib\core\win32.h(447) : error C2143: syntax error :
missing ',' before '*'
f:\perl\as1007-x86\lib\core\win32.h(447) : error C4430: missing type
specifier - int assumed. Note: C++ does not support default-int
If I then comment out the line
'CCFLAGS' => '-MT'
the project again builds successfully. This also adds all there options
to the compilation command:
-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE
-DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE
-DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DUSE_PERLIO -DPERL_MSVCRT_READFIX
And the question is what is to be considered best practice.
I ActivePerl and the C++ compiler from Visual Studio 2005. (And the module
for which I am modifying makefile.pl requires this compiler, and this
version of the compiler.)
--
Erland Sommarskog, Stockholm, [email protected]