NetworkArchitek
asked on
Error C2227 when compiling with XML Support
I have inherited a Visual C++ application. I am using Visual Studio 2005. It is *not* a .NET app. Whenever I compile I get 3 errors that read thus:
Error 476 error C2227: left of '->QueryInterface' must point to class/struct/union/generic type C:\Program Files\Microsoft Visual Studio 8\VC\include\comip.h 852
I have three lines that make a call like this in various placess:
::IXMLDOMDocumentPtr pXMLDoc = (MSXML2::IXMLDOMDocumentPt r)GetDocum ent();
If I comment out the "(MSXML2::IXMLDOMDocumentP tr)GetDocu ment();" it compiles fine. Of course, pXMLDoc is then not initialized. Now, this GetDocument() function signature is like:
void* CXMLInterface::GetDocument ()
Even if I comment out all of the code in that function and then just make it "return 0;" I still get the error.
Now, if you look at that original error it is in comip.h. That apparently is a standard include file. I have not modified that include file, it is stock. I don't know why there would be any problem with it. Googling this yields very little. The best I can come up with is that there is a mismatch in some kind of include file set between the SDK and the VS standard include set.
At the top of the file I have
#import <MSXML3.dll>
I also include a msxml.h which appears to have been generated, of course. This is the beginning of that file
-----------------------
// Created by Microsoft (R) C/C++ Compiler Version 14.00.50727.42 (67f0d8d7).
//
// c:\tmp\cacat\cacat\debug\m sxml.tlh
//
// C++ source equivalent of Win32 type library msxml.dll
// compiler-generated file created 10/07/06 at 14:30:45 - DO NOT EDIT!
-------------------------
I don't have that c:\tmp\cacat\.... file. Again this stuff was inherited and there is not anyone else I can talk to about it. It appears all this is just due to the XML stuff. So if anyone can give me the best route to get this solve ASAP I would really really appreciate it. Thanks.
Error 476 error C2227: left of '->QueryInterface' must point to class/struct/union/generic
I have three lines that make a call like this in various placess:
::IXMLDOMDocumentPtr pXMLDoc = (MSXML2::IXMLDOMDocumentPt
If I comment out the "(MSXML2::IXMLDOMDocumentP
void* CXMLInterface::GetDocument
Even if I comment out all of the code in that function and then just make it "return 0;" I still get the error.
Now, if you look at that original error it is in comip.h. That apparently is a standard include file. I have not modified that include file, it is stock. I don't know why there would be any problem with it. Googling this yields very little. The best I can come up with is that there is a mismatch in some kind of include file set between the SDK and the VS standard include set.
At the top of the file I have
#import <MSXML3.dll>
I also include a msxml.h which appears to have been generated, of course. This is the beginning of that file
-----------------------
// Created by Microsoft (R) C/C++ Compiler Version 14.00.50727.42 (67f0d8d7).
//
// c:\tmp\cacat\cacat\debug\m
//
// C++ source equivalent of Win32 type library msxml.dll
// compiler-generated file created 10/07/06 at 14:30:45 - DO NOT EDIT!
-------------------------
I don't have that c:\tmp\cacat\.... file. Again this stuff was inherited and there is not anyone else I can talk to about it. It appears all this is just due to the XML stuff. So if anyone can give me the best route to get this solve ASAP I would really really appreciate it. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what is the type of pXMLDoc?
if type is IXMLDOMDocument*, then you have to call it in the following way:
VARIANT_BOOL b;
pXMLDoc->load(variant, &b);
if type is IXMLDOMDocumentPtr, your code looks like fine.
There are some MSXML tutorials in this web site:
http://www.perfectxml.com/CPPMSXML/
if type is IXMLDOMDocument*, then you have to call it in the following way:
VARIANT_BOOL b;
pXMLDoc->load(variant, &b);
if type is IXMLDOMDocumentPtr, your code looks like fine.
There are some MSXML tutorials in this web site:
http://www.perfectxml.com/CPPMSXML/
ASKER
vbRetVal= pXMLDoc->load(variant);
creates error C2660: 'IXMLDOMDocument::load' " function does not take 1 arguments
I clicked on "Go to Definition" for the load() function and it is in the generated msxml.h. This is what it says in that header file
VARIANT_BOOL load (
const _variant_t & xmlSource );
That looks like one argument to me ... Any ideas? Thanks