mity / mctrl

C library providing set of additional user interface controls for Windows, intended to be complementary to standard Win32API controls from USER32.DLL and COMCTL32.DLL.
http://mctrl.org
229 stars 50 forks source link

Windows mCtrl build broke with Windows 10 SDK #59

Closed BigJim closed 6 years ago

BigJim commented 6 years ago

Like it says, unfortunately macros like "ID2D1RenderTarget_CreateBitmapFromWicBitmap" were marked "#pragma deprecated("ID2D1RenderTarget_CreateBitmapFromWicBitmap")" in SDK 10.0.10586.0, and now completely gone in SDK 10.0.16299.0,.

If you are using VS2017 you'ed normally want to use the default 10 SDK.

Builds fine if using the Win 8.1 SDK, just not the latest 10 version.
I tried simply replacing the missing macros but then there are other issues with undefined types now.

=================================== Update: Luckily this works, but not the best solution as you need to have an older version of "d2d1.h" laying around, etc. 1) Copy the older "d2d1.h" (in my case from Win 8.1 SDK) over to to "windrawlib" (the folder where "backend-d2d.h" is located). 2) Change the line in "backend-d2d.h" from '#include ' to '#include "d2d1.h"' to use the local search order instead of the global one.

Microsoft, you trolled me again..

mity commented 6 years ago

Thanks for the report, I'll take a look on it.

BTW, I have just installed fresh SDK version from https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk. Strange thing is that the webpage talks about the version 10.0.16299.15, but after installing it identifies itself as 10.0.15063.0.

But it seems to be new enough for reproducing the issue.

mity commented 6 years ago

Damn. It seems Microsoft has ripped C support out from <d2d1.h> altogether. OMG, why do they like to break stuff, for no obvious benefit?

Well, there are still some #ifdef D2D_USE_C_DEFINITIONS blocks in the header but they seem to be incomplete and they are likely just few snippets they forgot to remove with the rest of it. There is no C struct definition for the interfaces with the typical lpVtbl member pointing to virtual table for example.

I'm afraid the only possible "fix" is to provide our own replacement header. We already do that for dwrite.h and gdiplus.h (subdir windrawlib/dummy). But it is tedious and boring work, and it will get some time. Hopefully, I will persuade myself to do it later this week.

BigJim commented 6 years ago

Yea nuts. I searched around again today and could only find this so far: https://social.msdn.microsoft.com/Forums/en-US/b557dbb1-79d5-4a2d-b8fc-5dc07ab0637d/is-plain-c-actually-supported-for-direct2d Found no official word from Microsoft yet.

If I didn't know any better, I'd say the DirectX guy got tired/lazy updating the C support.

It is tedious as I started to do it myself, but gave up for a shortcut solution after I saw the struct/types missing. Come to think of it though, at at least with the Win 8.1 SDKd2d1.h, one might able to mostly copy over just the stuff between the "D2D_USE_C_DEFINITIONS" blocks.

Thanks for your most awesome control library!

BigJim commented 6 years ago

I think SDK 10.0.16299.0 came when I recently updated Visual Studio 2017 (off it's built in update notice feature).

mity commented 6 years ago

If I didn't know any better, I'd say the DirectX guy got tired/lazy updating the C support.

  1. I am wondering whether Microsoft's COM headers are generated by some IDL tool or whether they write it manually. Given how many such headers they manage, then laziness should imply they write/use such tool and it should then be quite easy to teach such tool to generate the C compatibility sugar as well.

  2. Even if they do it manually, I could understand if they would stop updating the C support for new COM interfaces. But they removed it and broke existing codebases. There is no danger why the old C support should ever stop working given the nature of binary compatibility of the COM interfaces if they just freeze it.

It is tedious as I started to do it myself, but gave up for a shortcut solution after I saw the struct/types missing.

Well, I find headers from mingw-w64 better for this kind of work. Microsoft SDK headers often contain MSVC-specific mannerisms. I am also unsure about licensing terms of Microsoft headers: Is it legal to copy&paste from it into a codebase under GNU LGPL? In comparison, <d2d1.h> from mingw-w64 is in Public Domain.

mity commented 6 years ago

Fixed by implementing windrawlib/dummy/d2d1.h. Builds for me in MSVC 2017 as well as in mingw-w64.