[Expat-discuss] cannot convert parameter from 'void (void *, const char *, const char ** )'

terrasurfer at knology.net terrasurfer at knology.net
Tue Mar 30 15:36:37 EST 2004


I am having problems compiling my C++ class using expat. I am
running on Windows 2000, using VC++ 6.0 (MS Visual Studio).
I have the correct library and include file. I have compiled the
example on this platform and also created a multi-threaded example which 
work fine. The examples didn't use classes.

A relevant snippet of the code I'm attempting to compile is below:



FUNCTION DEF'N.
---------------

int CNode::vLoadCNode(const char *strXMLBuffer)
{
    char buf[BUFSIZ];
    XML_Parser parser = XML_ParserCreate(NULL);
    int done;
    int depth = 0;

    XML_SetUserData(parser, &depth);
    XML_SetElementHandler(parser, _exp_startTagHandler, _exp_endTagHandler);
    XML_SetCharacterDataHandler(parser,_exp_charDataHandler);

    do {
    size_t len = fread(buf, 1, sizeof(buf), (struct _iobuf *)strXMLBuffer);
    done = len < sizeof(buf);
    if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) {
      fprintf(stderr,
              "%s at line %d\n",
              XML_ErrorString(XML_GetErrorCode(parser)),
              XML_GetCurrentLineNumber(parser));
      return 1;
    }
  } while (!done);


  XML_ParserFree(parser);

}


HANDLER DECLARATION AND DEFINITION
----------------------------------

    void XMLCALL  
    _exp_startTagHandler(void *userData, const char *name, const char **atts);
    
    
    void XMLCALL CNode::_exp_startTagHandler(void *userData, const char
*name, const char **atts)
    {
    
        //create a CNode this handler ALWAYS creates a CNode.
        CNode *newNode = new CNode();
    
        //set the name with the tag name sent to this handler.
        newNode->vSetName(name);
    
        //if something on the stack, set this node as a child of that,
        //otherwise push this node onto the stack.
        if(!_tempStack.empty())
        {
            _tempStack[_tempStackCounter]->vAddChild(newNode);
            _pushNode(newNode);
            _tempStackCounter++;
    
        }
        else
        {
            _pushNode(newNode);
            _tempStackCounter++;
    
        }
        
    }


COMPILER ERROR:
--------------
c:\surfacehums 1.0\code\shums_node\node.cpp(1381) : error C2664:
'XML_SetElementHandler' : cannot convert parameter 2 from 'void (void
*,const char *,const char ** )' to 'void (__cdecl *)(void *,const char
*,const char ** )'
        None of the functions with this name in scope match the target type

        
The offending line is in the call to XML_SetElementHandler. I'm not sure if
I need to define
the function as a function pointer or what? If someone has an idea of what
I'm doing wrong it would be 
greatly appreciated.



More information about the Expat-discuss mailing list