Suggestion to use common Win32 headers

Trevor Parscal trevorparscal at hotmail.com
Wed Mar 5 11:08:44 PST 2008


bobef Wrote:

> Hi guys,
> 
> I run into this problem often. Each [win32] library uses its own win32 headers, typically only what it needs. For example - phobos has some common headers, tango has some minimal win32 headers, dfl has its own, dwt has its own, etc... So if you use more than one of these libraries you run into conflicts. On top of that their win32 headers support is limited and you need yet another headers (which cause even more conflicts) or do what they do - manually copy paste from msdn, which sucks :) 
> 
> So how could this be solved? By the adoption of full set of the win32 headers by the both standard libraries - phobos and tango. Such comprehensive set of headers exists in the dsource/bindings/win32 project. So if these headers are present in the std lib, the the other major libraries like dfl, dwt, etc would not need to redefine the win32 api and one would be able to use the same headers which these libraries use, so you won't run into conflicts like void(HANDLE,UINT) does not match void(HANDLE,UINT).
> 
> Maybe there is other way around - I don't know, but this seems a pretty good solution to me.
> 
> Best regards,
> bobef

As the person who contributed Tango's minimal windows header, and also has authored a new even more restrictive header for my own project UniD, I feel I may be a good person to answer this question.

"Windows headers" can mean just windows.h or poitentially hundreds of files which for the majority of users are not needed. Even with automatic conversion software (h2d) it is a tedious process to get bug-free D modules from C header files.

So it's often been a question of scope; how many headers should we consider "common"?

My approach with UniD is the least complete [1] - only defining the things I need - however I personally suggest going this route to supplement what Tango already has, and if it's working for you, offering it as a patch to Tango.

The other issue is a licensing issue. When I hand write my own module from scratch based on documentation, I own it - or at least they don't own it and I can use it in anything without legal problems [2]. So even if you wrote a program that converted all the latest header files from a release of VisualStudio, there are licensing problems there. There are other renditions of the headers are are of an unrestricted nature [3] however, so if you were to take those, and convert them all, you could have what you want.

So there you have it - the answer is "nobody has taken the time to convert everything yet, but you certainly can!"

- Trevor

[1] http://www.dsource.org/projects/unid/browser/trunk/source/uni/lib/platforms/Windows.d

[2] AFAIK, but is this really true?

[4] http://www.mingw.org/mingwfaq.shtml#faq-w32api



More information about the Digitalmars-d mailing list