Windows SDK, Provide a direct way to download Header files (Ex: Windows.h) and allow the redistribution of the Header Files.

BoQsc 1 Reputation point

I'm aware of Windows SDK including the Windows.h header file.
The problem with Windows SDK is that it is a huge blob file that reach 1 Gigabyte of download size.
I'd like to know what is the way to directly download the Header files separately that are included in the Windows SDK.
Since I'm working on a Public Domain programming project, I'd like to distribute these header files as part of my project.
What is the correct and direct way to accomplish this?

A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,823 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,441 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,367 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 49,071 Reputation points

    You cannot do that. Here's the list of issues (ignoring legal issues).

    • Windows.h varies by OS version. Just because you targeted, say Windows 10, doesn't mean the Window 10.1 or Windows 11 versions won't work either.
    • Header files are just to make the compiler happy. They don't contain the actual code. To actually link the code you also need the .lib files. Therefore shipping the headers alone isn't sufficient to compile the code anyway.
    • Anybody who tries to use your code, especially if they are compiling for Windows, already has the SDK installed anyway. You wouldn't want your, potentially older, copy of windows.h to be used in lieu of the more current version.
    • Even if you did want your version of windows.h to be used then you might cause any consuming code to fail to compile as the header wouldn't line up with the .lib they would be importing anyway. This would be very confusing to figure out.
    • windows.h is a wrapper header that includes lots of other header files based upon various preprocessor flags. You'll end up shipping a lot more than just a single header file.

    I'm trying to understand why you feel that referencing windows.h in your code requires that you redist the Windows SDK files at all? If your code is using "Windows" features then that means anybody relying on your code is also going to need Windows dev tools so they'll already have the stuff you are trying to include. Just assume they will have it. For example if you are providing a Visual Studio solution then they are going to need Visual Studio which ships with the Windows stuff already. If you're using cmake instead then they still need the build tools which probably has the Windows files as well.

    If you're building a binary (EXE) then nobody needs header files as that is a compile only thing. If you're building a reusable library (DLL) then the only header(s) that are needed are those that define what your code exposes. If you are exposing Windows types then other devs are still going to need the Windows components anyway so you are not actually saving anything.

    Unfortunately this is how C++ works and always has. If you don't like the limitations of C++ then you'll need to look at another language. While there has been progress made over the years to make C++ more modular (such as vcpkg or C++ modules) none of these would actually solve your direct problem as Windows (which is C++ agnostic) doesn't provide either of these features (yet).

    If you really, really don't want to rely on windows.h then you could redefine the (hopefully limited) types you do need. But since you cannot control the order in which headers are included (that is up to the cpp file) then you would need to conditionally define them if they weren't already defined. But this still doesn't work around the issue that the .lib files are also needed for any functionality not directly inlined in the header files.

    0 comments No comments