<p>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.</p>

<p>This would be a huge problem for a widely-used library like DirectX.</p>

<p>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.</p>

CC BY-SA 4.0
2018-07-23T10:42:29.853Z
2018-07-23T10:42:29.853Z
Dan Hulme
<p>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++?</p>

<c++><directx><direct3d>
Why does DirectX use COM pointers and interfaces?
mbl
# Why does DirectX use COM pointers and interfaces?

(Asked by: username_0 on 2018-07-22)

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++?

**Tags:** c++, directx, direct3d


---

## 1 answers

### Answer by username_1 on 2018-07-23. Score: 5 | Accepted answer

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.


---

