C语言中__uuidof的替代方法 [英] Alternative to __uuidof in C

查看:433
本文介绍了C语言中__uuidof的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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.

http://social.msdn.microsoft .com/Forums/zh-CN/vclanguage/thread/1306b57f-4b75-4f0c-b4f3-9bcc1e3a0dd6

来自d3d11.h:

EXTERN_C const IID IID_ID3D11Texture2D;

使用它代替__uuidof(ID3D11Texture2D).

这篇关于C语言中__uuidof的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆