[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1834
  • Last Modified:

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::IXMLDOMDocumentPtr)GetDocument();

If I comment out the "(MSXML2::IXMLDOMDocumentPtr)GetDocument();" 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\msxml.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.
0
NetworkArchitek
Asked:
NetworkArchitek
  • 2
1 Solution
 
OnegaZhangCommented:
Try the following:
IXMLDOMDocument* pDomDoc = (IXMLDOMDocument*)GetDocument();
::IXMLDOMDocumentPtr pXMLDoc = pDomDoc;

Because IxxxPtr is a smart pointer and will call QueryInterface() in its ctor, but it is not available in (void*) type.
0
 
NetworkArchitekAuthor Commented:
Hey thanks, we're making a little progress I think. I made that change in two places and it got rid of that error. Now this line:

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
0
 
OnegaZhangCommented:
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/
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now