none
error C2146: syntax error : missing ';' before identifier 'IXMLDOMImplementation'

    Question



  • Hello,

    here's my problem, I have a unmanaged C++ project U which has the U.h file that includes msxml2.h and is making use of the xml interfaces defined in that header file. Project U compiles without error and produces the library U.dll. I also have a managed C++ project M which has a M.h file that includes the U.h file from the U project. Well, when I compile the M project I get a bunch of errors all in the msxml2.h file, please see them listed below.

    I tried to add "using namespace MSXML2;" in my h files but that doesn't work either. It is complaining that namespace MSXML2 doesn't exist.
    Any clues on what should I look for? How can I solve this issue? What is causing it? Thanks a lot for any input!

    These are the first compilation errors I get compiling the M project (managed C++ project)

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(49) : error C2146: syntax error : missing ';' before identifier 'IXMLDOMImplementation'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(49) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(49) : error C2146: syntax error : missing ';' before identifier 'IXMLDOMImplementation'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(49) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(49) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(49) : error C2086: 'int IXMLDOMImplementation' : redefinition
            C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(49) : see declaration of 'IXMLDOMImplementation'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(55) : error C2146: syntax error : missing ';' before identifier 'IXMLDOMNode'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(55) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(61) : error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocumentFragment'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(61) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(67) : error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocument'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(67) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(73) : error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocument2'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(73) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(79) : error C2146: syntax error : missing ';' before identifier 'IXMLDOMDocument3'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\msxml2.h(79) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
    Wednesday, February 24, 2010 8:18 PM

Answers

  • Here is the relevant portion of msxml2.h, where your compile runs into trouble:

    #ifndef __msxml2_h__
    #define __msxml2_h__
    
    #if defined(_MSC_VER) && (_MSC_VER >= 1020)
    #pragma once
    #endif
    
    /* Forward Declarations */ 
    
    #ifndef __IXMLDOMImplementation_FWD_DEFINED__
    #define __IXMLDOMImplementation_FWD_DEFINED__
    typedef interface IXMLDOMImplementation IXMLDOMImplementation;
    #endif 	/* __IXMLDOMImplementation_FWD_DEFINED__ */
    
    

    Line 49 is where the IXMLDOMImplementation interface is defined. Just above that is some preprocessor code that is used to "guard" the header from being included twice in a single source file. That is not working in your second project. You have said that it is being included by another include file, but if you are using precompiled headers for your source files, then that include file probably should not include msxml2.h, but you might try including msxml2.h in "stdafx.h" and nowhere else. That will help get the order right, and the guards should work properly, then. (I think somehow __IXMLDOMImplementation_FWD_DEFINED__ is not defined, but the compiler is making a second pass into that include file, and the MSC_VER < 1020.)
    • Marked as answer by iamveritas Thursday, February 25, 2010 2:18 AM
    Wednesday, February 24, 2010 8:49 PM

All replies

  • Here is the relevant portion of msxml2.h, where your compile runs into trouble:

    #ifndef __msxml2_h__
    #define __msxml2_h__
    
    #if defined(_MSC_VER) && (_MSC_VER >= 1020)
    #pragma once
    #endif
    
    /* Forward Declarations */ 
    
    #ifndef __IXMLDOMImplementation_FWD_DEFINED__
    #define __IXMLDOMImplementation_FWD_DEFINED__
    typedef interface IXMLDOMImplementation IXMLDOMImplementation;
    #endif 	/* __IXMLDOMImplementation_FWD_DEFINED__ */
    
    

    Line 49 is where the IXMLDOMImplementation interface is defined. Just above that is some preprocessor code that is used to "guard" the header from being included twice in a single source file. That is not working in your second project. You have said that it is being included by another include file, but if you are using precompiled headers for your source files, then that include file probably should not include msxml2.h, but you might try including msxml2.h in "stdafx.h" and nowhere else. That will help get the order right, and the guards should work properly, then. (I think somehow __IXMLDOMImplementation_FWD_DEFINED__ is not defined, but the compiler is making a second pass into that include file, and the MSC_VER < 1020.)
    • Marked as answer by iamveritas Thursday, February 25, 2010 2:18 AM
    Wednesday, February 24, 2010 8:49 PM
  • adding msxml2.h in stdafx.h didn't solve it, the result is exactly the same.

    in the mean time I created an empty C++ unmanaged project to produce a dll (most basic project, no ATL, no MFC, all default properties). completely empty.
    and if I add
    #include <msxml2.h>
    to the cpp file I get the same errors as I was listing above.

    adding
    #import "MSXML3.dll" named_guids
    instead works just fine.

    the problem is if I use
    #import "MSXML3.dll" named_guids
    in my original projects I get other errors, see below the firsts of them which are followed by many other very similar:

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(1973) : error C2872: 'BIND_OPTS' : ambiguous symbol
            could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(1891) : tagBIND_OPTS BIND_OPTS'
            or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::BIND_OPTS'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(1976) : error C2872: 'BIND_OPTS' : ambiguous symbol
            could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(1891) : tagBIND_OPTS BIND_OPTS'
            or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::BIND_OPTS'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(2438) : error C2872: 'FILETIME' : ambiguous symbol
            could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\windef.h(377) : _FILETIME FILETIME'
            or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::FILETIME'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(2442) : error C2872: 'FILETIME' : ambiguous symbol
            could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\windef.h(377) : _FILETIME FILETIME'
            or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::FILETIME'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(2836) : error C2872: 'FILETIME' : ambiguous symbol
            could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\windef.h(377) : _FILETIME FILETIME'
            or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::FILETIME'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(3482) : error C2872: 'FILETIME' : ambiguous symbol
            could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\windef.h(377) : _FILETIME FILETIME'
            or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::FILETIME'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(3483) : error C2872: 'FILETIME' : ambiguous symbol
            could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\windef.h(377) : _FILETIME FILETIME'
            or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::Runtime::InteropServices::FILETIME'

    Wednesday, February 24, 2010 11:02 PM
  • Actually doing what you suggested worked in my original project, iiihhhhaaaaaa! thanks a lot.
    but now I am stuck with the other situation, the ambiguous symbols errors.

    I posted another question related with those ones here
    http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/8dc7fc5a-4b44-4df1-bf8f-4201864ac7c0

    Thanks a lot Jinzai!

    Thursday, February 25, 2010 2:17 AM