Search code examples
c++libxml2

previous declaration of 'namespace reference { }'


I am getting compilation error when I compiling my code with libxml2.

File Reference.h already exists in my code and being used by many other files:

Reference.h
namespace reference // BEGIN OF namespace reference
{

}

But I am getting error when I am compiling my code with libxml2:

libxml2/libxml/SAX.h:116: error: 'void reference(void*, const xmlChar*)' redeclared as different kind of symbol

libxml2/libxml/SAX.h
XMLPUBFUN void XMLCALL reference (void *ctx,
       const xmlChar *name);

Is there a way to resolve this error without modifying my file Reference.h?

Thanks for your help.


Solution

  • Basically, disable SAX.h. That's a deprecated interface, which doesn't bother to do any namespacing or use any standard prefix for its symbols. Instead, use SAX2.h, which (in addition to other improvements) prefixes everything with xmlSAX2.

    To keep the deprecated stuff out of your libxml2, when you run configure make sure not to pass the with_legacy option.