如何使用nsCOMPtr正确调用do_QueryInterface

How to properly call do_QueryInterface with nsCOMPtr

本文关键字:do QueryInterface 调用 何使用 nsCOMPtr      更新时间:2023-10-16

我正在使用Gecko SDK 32.0.2 for win32。我有一段代码,应该可以工作:

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

但是,编译器说:

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

可用的过载有:

do_QueryInterface(nsISupports* rawPointer)

do_QueryInterface(already_AddRefed<T>&)

在这种情况下,如何正确地进行函数调用?

我会自己回答。。。正如我在评论中所写的,我没有得到任何回答,但我找到了原因。它与消息没有直接关系,这是由于VSC++项目属性造成的:将WChar_t视为内置类型应设置为"是(/Zc:WChar_t)"