VTD-XML C Version 'get' macro conflict

Help
2010-07-02
2013-05-15
  • Hi,

    I downloaded 'vtd-xml 2.8 C' and the win vc++ solution and compiled them into static libraries. Then I included the headers into my own project and linked to the library.

    However, trying to compile yields an error wherever I have the word 'get' in my code,
    Basically, vtd-xml is defining a macro "get" in the arrayList.h (second to last line)

    How can I get this to work nicely with my c++ program?

     
  • jimmy zhang
    jimmy zhang
    2010-07-05

    what is the error message ?

     
  • The error message:
    warning C4003: not enough actual parameters for macro 'get'
    error C2039: 'any' : is not a member of 'std::basic_istream<_Elem,_Traits>'
    UtilFunctions.cpp(7): error C2227: left of '->storage' must point to class/struct/union/generic type
    UtilFunctions.cpp(7): error C2059: syntax error : ']'

    This is part of my code in my own project:
    char any;
    std::cin.get(any);

    In any case, I went ahead and just put a
    #ifdef get
    #undef get
    #endif

    next to the include of the vtd-xml headers.

    Though, now I am getting a problem with linking…
    vtd-xml-win64D.lib(l8.tab.obj) : error LNK2019: unresolved external symbol createVariableExpr referenced in function yyparse

    that's from the static library I compiled from your source. Looking through your source, I only see a call to that function, and a declaration.

     
  • jimmy zhang
    jimmy zhang
    2010-07-09

    did you compile the vtd-xml as a c++ project or c project? you should configure the compiler so it is treated as a C project

     
  • Yup, saw that in the FAQ :) Yeah, they're all compiled as C rather than C++. I double checked, recompiled, and still no luck.

    Does it matter that the project linking the vtd-xml static lib is compiled as a c++?

     
  • jimmy zhang
    jimmy zhang
    2010-07-09

    how did you include the vtd-xml headers? did you include in a extern C declaration block?

     
  • extern "C" {
    #include <vtd-xml.h>
            #ifdef get
            #undef get
            #endif
    struct exception_context the_exception_context;
    }

    Is placed in my precompiled header. I used the undef to remove the macro… which works for removing the macro problem. Still struggling with the createVariableExpr problem :(

     
  • jimmy zhang
    jimmy zhang
    2010-07-10

    what createVariableExpr problem?

     
  • Oh, I mentioned at the end of an earlier post:

    Though, now I am getting a problem with linking… vtd-xml-win64D.lib(l8.tab.obj) : error LNK2019: unresolved external symbol createVariableExpr referenced in function yyparse