2
$\begingroup$

I have a rudimentary understanding of COM and I know that its main purpose is to enable interoperability between programs written in different languages. However I dont understand why that is useful to the DirectX api. Is it because DirectX has to make calls to the windows api which are written in C whereas DirectX is written in C++?

$\endgroup$
4
$\begingroup$

C++ has no defined ABI, so C++ programs can't link to libraries that were compiled with a different compiler. In addition, MS's Visual Studio C++ compiler is not ABI-stable, so you don't just have to use the same compiler: you have to use the same version that the library was compiled with.

This would be a huge problem for a widely-used library like DirectX.

COM doesn't just enable interoperability between different languages, but also between different C++ compilers. In fact, I'd say this is its main use, and language compatibility is less used. By being a COM library, DirectX can avoid application developers needing to care what compiler it was compiled with. Application developers are free to use a Visual Studio version of their choice, or a completely different C++ compiler.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.