C语言中__uuidof的替代方法 [英] Alternative to __uuidof in C
问题描述
我正在使用DirectX的C项目工作,但遇到了问题.某些DX调用需要一个IID
对象,该对象通常由__uuidof
生成.这需要做的一件事就是创建一个RenderTargetView. DirectX示例/教程可以做到这一点:
I'm working with a C project that's using DirectX and I've run into a problem. Certain DX calls require a IID
object, typically generated with __uuidof
. One thing this is required for is creating a RenderTargetView. The DirectX samples/tutorials do this:
ID3D11Texture2D* pBackBuffer = NULL;
hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );
当我尝试在C代码中调用__uuidof
时,出现编译器错误:Error 19 error C4233: nonstandard extension used : '__uuidof' keyword only supported in C++, not C
. DirectX具有C接口,因此我想必须有一种方法可以执行此操作,但是我不知道它会是什么.有人知道吗?
When I try to call __uuidof
in my C code, I get an compiler error: Error 19 error C4233: nonstandard extension used : '__uuidof' keyword only supported in C++, not C
. DirectX has a C interface, so I imagine there must be a way to do this, but I have no idea what it would be. Anyone know?
推荐答案
__uuidof
仅在C ++中可用,如错误所述.我认为您已经在DX标头文件中找到了C接口的GUID.
__uuidof
is only available in C++, as error described. I think you already have definitions of the GUIDs of the interfaces for C available in DX header files.
来自d3d11.h
:
EXTERN_C const IID IID_ID3D11Texture2D;
使用它代替__uuidof(ID3D11Texture2D)
.
这篇关于C语言中__uuidof的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!