错误C2664:无法转换IDWriteFactory2 **'到了'IUnknown **'

时间:2014-09-24 14:36:05

标签: c++ directx-11

以下的mwe基本上是从this example中提取的。完整的示例编译并正常工作,但我的mwe不能使用Visual Studio 2013编译,我不明白为什么不。

#include <dwrite_2.h>
#include <atlbase.h>

using namespace std;


void main()
{
    IDWriteFactory2* m_spdwriteFactory;

    DWriteCreateFactory(
    DWRITE_FACTORY_TYPE_SHARED,
    __uuidof( IDWriteFactory2 ),
    &( m_spdwriteFactory )
    );
}

错误消息显示为:

  
    

------ Build build:Project:Test,Configuration:Debug x64 ------

  
     

1&GT; Source.cpp

     

1&gt; Source.cpp(16):错误C2664:&#39; HRESULT DWriteCreateFactory(DWRITE_FACTORY_TYPE,const IID&amp;,IUnknown **)&#39; :无法从IDWriteFactory2 **&#39;转换参数3到&#39; IUnknown **&#39;

     

1&GT;指向的类型是无关的;转换需要reinterpret_cast,C风格的转换或函数式转换

     

==========构建:0成功,1失败,0最新,0跳过==========

1 个答案:

答案 0 :(得分:0)

您需要将m_spdwriteFactory强制转换为IUnknown **以修复编译错误。请参阅此处的示例:http://msdn.microsoft.com/en-us/library/windows/desktop/dd368040(v=vs.85).aspx