[xml] Problems with libxml2-2.6.4


I have a problem with libxml2 (2.6.4).

The problem lies with xmlSAXParseFile(). This function is defined as:

                xmlSAXParseFile         (xmlSAXHandlerPtr sax,
                                         const char *filename,
                                         int recovery);

(You'll note that argument 1 is xmlSAXHandlerPtr. However, if code does the

        xmlDocPtr doc = xmlSAXParseFile(&xmlDefaultSAXHandler, filename, 0);

Then there is an issue, since xmlDefaultSAXHandler() is defined as:

XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void);

(With threads enabled, XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler

This means that compiling code that uses xmlSAXParseFile with
xmlDefaultSAXHandler will generate warnings since the function expects
a  XMLSAXHandlerPtr for the first argument but gets xmlSAXHandlerV1*.

I can see that there is some kind of mismatch between the xmlSAXParseFile()
function and the definition of xmlDefaultSAXHandler, but it's not clear how
best to address it.

How should this best be corrected? Is it correct to just cast the value
of &xmlDefaultSAXHandler to xmlSAXHandlerPtr?

Gary Pennington
Solaris Kernel Development,
Sun Microsystems
Gary Pennington sun com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]