Using XAudio2 in C

1.1k views Asked by At

I am working on a C program using Visual Studio 2015 on Windows 10. When I include XAudio2.h I get a few hundred compiler errors, I believe the errors all stem from this one:

Error C2485 'uuid': unrecognized extended attribute

Is there anyway to get XAudio2 working with a C application?

1

There are 1 answers

2
Chuck Walbourn On BEST ANSWER

In short, the latest versions of XAudio2 (XAudio 2.8 in the Windows 8.x SDK, XAudio 2.9 in the Windows 10 SDK) don't support C, only C++.

The older XAudio 2.7 from the deprecated DirectX SDK builds with C, although it's had basically no testing from C. In fact, DirectX usage from C rather than C++ hasn't really been tested or well supported in a very, very long time. The MIDL compiler used for generating COM interface headers still has a lot of C-related support macros and elements from back when C usage was a first-class citizen, but this stuff is definitely in an "as is" state that gets little to no test coverage.

You can continue to frustrate yourself, you can wrap all the C++ code up in your own C callable wrapper, or just start using C++.

See this post and this post for important information about using VS 2015 with the legacy DirectX SDK.