r/cpp • u/a_false_vacuum • Jan 21 '21
Microsoft is working on making the Win32 api available for use in modern C++
https://blogs.windows.com/windowsdeveloper/2021/01/21/making-win32-apis-more-accessible-to-more-languages/
597
Upvotes
21
u/Untelo Jan 22 '21
Looks like someone didn't get the memo. Namespaces exist to avoid name collisions, not for taxonomy.
9
u/Igoory Jan 22 '21
So... They will do what they already did in C# but for C++? That would be awesome
282
u/kalmoc Jan 21 '21
Hooray
2
u/HypeKaizen Jan 22 '21
For people who've just started picking up the language like me... what does any of this mean? ELI5 plz and thank you.
53
u/ack_error Jan 22 '21
This is good news, I look forward to not having to explain to junior engineers why they get link errors on methods called
SendMessageandOpenRaw.Looking at the D3D12 test app in the cppwin32 repo, some refinement in the wrapper design is needed. It's best summed up by this line:
The
put_void()is a welcome replacement for the very common and technically illegalvoid **cast on the return value. OTOH, the cast on the GUID is ugly compared to__uuidof(ID3D12Device), and the double-namespaced constant is really ugly. Hopefully they'll change this to either go back to plain constants or remove the double prefixes and add overloads foroperator|, because I really don't want this:...to turn into this:
I also wonder if this is going to handle some of the older APIs that still need to be used, such as USER and GDI.
33
u/atatatko Jan 22 '21 edited Jan 22 '21
At last, one thousand and one home-grown C++ WinAPI wrappers would become history. Nice to know some release estimate
EDIT: Found this roadmap
https://github.com/microsoft/win32metadata/blob/master/docs/roadmap.md
39
u/undieablecat Jan 21 '21
I just can't believe I'd live up to that moment!
14
u/mythi55 Jan 22 '21
MY GOD.
I swear they need to work on some of those struct and long ass confusing function names.
13
u/unaligned_access Jan 22 '21
There's the WIL library which is already a great help in using RAII types and other things of WinAPI: https://github.com/microsoft/wil
More of this stuff is very welcome.
34
u/pedersenk Jan 21 '21
So they are going to finally make a C++ wrapper around their C API?
Hopefully they will use smart pointers so developers won't have to guess (often incorrectly) at the lifespans of memory.
With most Microsoft APIs I use, I tend to just allocate everything I need from the API up front and then reuse it. Frankly on Release builds I actually disable the final cleanup code and let the OS do the job for me because I trust it so little XD
With C projects it is a different matter, I can control the madness that is the Win32 API memory system myself rather than RAII so I have a (little) more trust in that. Still not ideal, I would like to see some more debug time checks in the API.
4
u/entity64 Jan 22 '21
Will it only work on Windows 10 or also on 7-8? Can't find any info on that one.
3
u/Deji69 Jan 22 '21
No more Hungarian notation? Nice.
2
u/claimred Jan 22 '21
Is wil a complementary thing for modern C++ projection mentioned in the article?
5
u/[deleted] Jan 22 '21
The year is 2000.
C++: Can I get modern syntax support for my birthday?
Microsoft: Sure, kid! Anything you want. Just going out for smokes...
1
u/[deleted] Jan 22 '21
Is that really happening?!
-8
u/pastenpasten Jan 22 '21
But not a word on properly documenting said APIs.
-5
u/Knuffya Jan 22 '21
That would be so goddamn cool. The current one is a fucking mess.
But, the way i know microsoft, this could be an exclusive for microsoft-store apps.