




  • As well as being full of non-standard extensions , the SDK headers also define a bunch of annoying macros, e.g. #define min ... and max which break standard-conforming programs – M.M May 17 '18 at 21:21



  • 1
  • 2

This answer is for 2018, and as far as I know it applies to all versions of Windows since Vista (updates providing).

The short answer is: you can't. Or more precisely, you can, but you will be pulling teeth every step of the way, spending countless man-hours fighting to get the API to work for you rather than against you, and it's simply a question of whether that's worth it to you.

The Windows API is by design going to be nightmarish to use without MSVC, because Microsoft wants you to use their entire development solution, and they don't give you a choice to avoid Visual Studio if you use their libraries. While it may seem convenient and sensible that the OS ships with the Windows SDK for free, it won't work without the C standard library, which is provided as a download from Microsoft. When you download this library through the installer, you'll find that Microsoft's UCRT depends on headers only found in the Visual C++ package, which is a 600MB+ download and consumes over 2GB when installed. And after all that, your compiler will default to choking on Microsoft's custom dialect of C, which isn't C99 but uses line comments and has countless other traps specifically designed to trip up sane compilers.

The above also doesn't even scratch the surface of legal that your team might have to delegate to cost even more money so you can figure out what's redistributable and under what terms. MinGW's libraries solve not only the legal concerns for the standard libraries (thanks to the GPL exception clause), but also make it painless to use in actual ISO C/C++.

My experience with this problem stems from a project I'm working on to develop a codebase using a unified LLVM-based build process. Everything works well enough on Linux and macOS, but on Windows without MinGW it has taken me days to failingly sort through this, and I haven't even gotten into the hiccups that there will inevitably be during linking with LLD. It's just not worth it to use anything Microsoft unless you're using MSVC, because Microsoft says go all the way or go home, and they put their code where their mouth is with that.

Your Answer

