With C (not C++) (i.e. if D2D_USE_C_DEFINITIONS is #defined), <d2d1.h> has two kinds of issues in definitions of macros <interfacename>_<methodname>() for methods inherited from a base interface.</methodname></interfacename></d2d1.h>
Both issues can be seen inn this snippet for ID2D1HwndRenderTarget:
...
#define ID2D1HwndRenderTarget_QueryInterface(this,A,B) (this)->lpVtbl->Base.Base.Base.QueryInterface((IUnknown*)this,A,B)
#define ID2D1HwndRenderTarget_AddRef(this) (this)->lpVtbl->Base.Base.Base.AddRef((IUnknown*)this)
#define ID2D1HwndRenderTarget_Release(this) (this)->lpVtbl->Base.Base.Base.Release((IUnknown*)this)
#define ID2D1HwndRenderTarget_GetFactory(this,A) (this)->lpVtbl->Base.Base.GetFactory((ID2D1Resource*)this,A)
#define ID2D1HwndRenderTarget_BeginDraw(this) (this)->lpVtbl->Base.BeginDraw(this)
#define ID2D1HwndRenderTarget_Clear(this,A) (this)->lpVtbl->Base.Clear(this,A)
#define ID2D1HwndRenderTarget_CreateBitmap(this,A,B,C,D,E) (this)->lpVtbl->Base.CreateBitmap(this,A,B,C,D,E)
...
Some method definitions do not have this in parentheses after the cast, which can evaluate to undesired results with arguments like e.g. ID2D1HwndRenderTarget_AddRef(somestruct->d2d1_resource).
Other methods lack the casting of this altogether, causing many gcc warnings about incompatible arguments.
After a glimpse, many other interfaces in the <d2d1.h> and also <d2d1effectauthor.h> (ID2D1EffectImpl) have the same problem.</d2d1effectauthor.h></d2d1.h>
Oops,
ID2D1HwndRenderTarget_AddRef(somestruct->d2d1_resource)is ok of course, due the operator priority (->is higher prioroty then the cast). But that said the macro definitions are still broken...Attaching patch fixing the issue.
Ping. Can you please review and apply the patch?
Sorry, looks like the ticket fell through the cracks, v3.x and master should now be fixed.
Unfortunately, this is not actually fixed. Seems the patch was applied only partially, for some reason unknown to me. :-(
As of current head in master, many interfaces still have the macros without the cast, although they forward the call to the Base (i.e. to the incompatible pointer). For example, see methods of ID2D1HWNDRenderTarget inherited from ID2D1RenderTarget,
ditto for methods of ID2D1GeometrySink inherited from ID2D1SimplifiedGeometrySink. (There may be even more, but these just triggered warnings in some my code.)
The original patch does cover those cases.
([Off topic] Ugh: the sf.net does not provide an option to reopen the issue?)
Done, I reverted the previous change and reapplied the patch to master and v4.x.
Seems ok now. Thanks Jonathan.