On Windows programming
I always find myself going through the same motions when trying to programming on Windows: excitement, bewilderedness, frustration, relief. It’s exciting to find new libraries and frameworks that seem to deliver exactly the functionality I require. I feel bewildered because I don’t think I’ve ever come across a Windows C/C++ API that immediately makes sense to me. Then follows a time of frustration, often a rather long period too, when I try to use the library/framework to solve the problem I have. At some point I hit that stage where my little project is debugged into behaving properlyi and a sense of relief comes over me.
One thing that never ceases to amaze me is how many small surprising things there are lurking just under the hood in Windows:
Want to print an error message? GetLastError gives you an error value and FormatMessage whips it into a nice printable string. Take a good long look at
FormatMessage. Where is the convenience function a lástrerror?Another thing is the surprising order of paths that is searched for DLLs. By putting
PATHso far down the list and completely leaving out an equivalent ofLD_LIBRARY_PATHthey actively encourage developers to copy DLLs into the home dirs of executables. I suspect this is inevitable given the DLL-hell phenomenon on Windows. It’s nonetheless extremely irritating when developing against a non-standard DLL (i.e. one that isn’t installed in\windows\system32).The utter confusion I experience when trying to figure out just where to find the correct framework to use. There is considerable overlap between Visual Studio and the Windows Platform SDK. To add more confusion there are sometimes other frameworks that overlap the both of them, e.g. Debugging Tools for Windows provides
dbghelp.{dll,h}, both of which are provided in slightly different versions in the other placesii.The lack of fixes for known issues, e.g. the version of
dbghelp.hincluded in Debugging Tools for Windows can’t be included as is because it lacks the definition of a macro. The webpage announcing version 6.6.7.5 was updated 18 July, 2006. One would think that gives Microsoft ample time to address the issue, but no such luck.
Well, that’s enough of ranting for one night…