Subject: | LibXSLT will not compile with Microsoft C compiler |
Date: | Wed, 11 Jan 2012 17:40:16 -0500 |
To: | <bug-XML-LibXSLT [...] rt.cpan.org> |
From: | "Adcock, Stephen W" <StephenW.Adcock [...] NRCan-RNCan.gc.ca> |
XML::LibXSLT-1.75
Perl v5.14.2
MS Windows Server 2008 R2, with Visual Studio 2010 (fully patched)
There are two places in LibXSLT.xs where code precedes declarations.
This, of course, is quite valid with C99, but Microsoft's C compiler
still does not support C99. The compilation fails with the misleading
error "C2275: illegal use of this type as an expression". The changes
to LibXSLT.xs, to make it msvc-compatible, are trivial:
1. Lines 268 to 289 (in LibXSLT__function):
const char * cls = "XML::LibXML::Node";
xmlNodePtr tnode = NULL;
SV * element = NULL;
int i;
for(i=0; i < nodelist->nodeNr; i++ ){
tnode = nodelist->nodeTab[i];
/* need to copy the node as libxml2 will
free it */
if (tnode->type == XML_NAMESPACE_DECL) {
element = sv_newmortal();
cls = x_PmmNodeTypeName( tnode
);
element = sv_setref_pv( element,
(const char
*)cls,
(void
*)xmlCopyNamespace((xmlNsPtr)tnode)
);
}
else {
xmlNodePtr tnode_cpy =
xmlDocCopyNode(tnode,INT2PTR(xmlDocPtr,x_PmmNODE(SvPROXYNODE(owner_doc))
),1);
if( tnode_cpy == NULL )
break;
element =
x_PmmNodeToSv(tnode_cpy,SvPROXYNODE(owner_doc));
}
XPUSHs( sv_2mortal(element) );
Enclose the lines in curly brackets, and optionally reverse the logic of
the "if ..." statement on lines266-7.
2. Line 541 (in LibXSLT_context_element):
dSP;
Move the dSP macro up to the beginning of the function.
Cheers,
Steve Adcock
Geochemist
Geological Survey of Canada
Message body is not shown because it is too large.