3 ms·
This has always bugged me as well. I've generally solved this by wrapping things in a struct. Type checking will use the (incompatible) wrappers and a modern co
by Reelin 6y ago
This has always bugged me as well. I've generally solved this by wrapping things in a struct. Type checking will use the (incompatible) wrappers and a modern compiler should optimize them away. To avoid strict aliasing violations when converting between equivalent wrapped types you can use a union and employ a function to hide the verbosity.
I have no idea if this is the "right" way to do things, but it seems to work.
- alternatetwo 6y agoThat's what Microsoft did from some version on in their build tools, all the HANDLE's etc used to just be typedef void , now they're a dummy struct each (HANDLE__ ). Seems to be a good solution.
- pjmlp 6y agoThat was already opt-in back in the Windows 3.1 days, but few bothered to use it as such. Back when I was doing pure Windows C for a while, this helped quite a bit, Basically you had to #include<windowsx.h> and define the STRICT macro. There were also several utilities that made it much easier to deal with events, dialogs and callbacks. https://docs.microsoft.com/en-us/windows/win32/api/windowsx/ https://docs.microsoft.com/en-us/windows/win32/api/windowsx/ https://jeffpar.github.io/kbarchive/kb/083/Q83456/ https://jeffpar.github.io/kbarchive/kb/083/Q83456/ I got to learn it via the "Programmer's introduction to Windows 3.1" book, https://archive.org/details/programmersintro00myer https://archive.org/details/programmersintro00myer