With D2D_USE_C_DEFINITIONS, quite a lot of Direct2D headers seem to be badly broken.
I was namely bitten by <d2d1_1.h> macro ID2D1DeviceContext_CreateSolidColorBrush() which seems to assume that method CreateSolidColorBrush is in its vtable and not its base interface.
Considering from a brief look, the same kind of issue seems to be quite widespread in multiple D2D headers.
Btw, as these COM interface issues are endemic, I wonder whether it wouldn't be good to harden the headers from this kind of errors. Few points how the situation might be improved come to my mind:
The macros might be replaced with inline functions. All such issues would then be much more easily detected even for methods which are rarely used.
Another option might be to use an anonymous union and struct like in this pattern:
``` C
struct IDerivedInterfaceVtbl {
union {
IBaseInterfaceVtbl base;
struct {
... // all inherited methods of IBaseInterfaceVtbl
}
... // methods added by IDerivedInterfaceVtbl
}
}
```
This would make the vtable agnostic to either "style" of macros, and might be perhaps also beneficial if there's some code out there that accesses the vtables by hand instead of the macro wrappers.
Perhaps this could somehow be (re)used: https://github.com/mmozeiko/c_d2d_dwrite as those seem to be in good shape.
(I use them for now as a workaround. The only issue with those is that with gcc one has to #define WIN_NOEXCEPT to be empty, and include "cdwrite.h" before "cd2d.h" as gcc errors with the "incomplete enum" which I assume is some C extension MSVC might accept.)
But IDK whether it might be a legal problem as those seem to be generated from some Microsoft-provided metadata.
Hmm, SF somehow managed to break the formatting. Reposting the pattern as it seems there's no way I can edit it the original.