Search code examples
c++firefox-addonxpcom

How to properly call do_QueryInterface with nsCOMPtr


I'm using Gecko SDK 32.0.2 for win32. I have this snippet of code, that should work:

nsCOMPtr<nsIDOMDocument> doc;
dwi->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentXBL> xbl(do_QueryInterface(doc));

But, the compiler says:

no instance of overloaded function 'do_QueryInterface' matches argument list nsCOMPtr<nsIDOMDocument>

Available overloads are:

do_QueryInterface(nsISupports* rawPointer)

and

do_QueryInterface(already_AddRefed<T>&)

How to properly make the function call in this case?


Solution

  • I will self-answer it... As I've written in the comment, I got no answer on ask.m.o., but I found out the cause. It was not related to the message directly, it was due to VSC++ project properties: Treat WChar_t as Built in Type should be set to "Yes (/Zc:wchar_t)"