Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
858 views
in Technique[技术] by (71.8m points)

visual studio - Alternative to __uuidof in C

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 );

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

__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/en-US/vclanguage/thread/1306b57f-4b75-4f0c-b4f3-9bcc1e3a0dd6

From d3d11.h:

EXTERN_C const IID IID_ID3D11Texture2D;

Use this instead of __uuidof(ID3D11Texture2D).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...