Yet another effort at translating the Win32 API headers
Don Clugston
dac at nospam.com.au
Wed Mar 29 07:48:37 PST 2006
Stewart Gordon wrote:
> Don Clugston wrote:
>> Stewart Gordon wrote:
> <snip>
>>> Now, who's going to contribute?
>>
>> I hope that I can do a bit.
>
> Excellent!
>
> <snip>
>>> Defining a set of version identifiers for the supported Windows
>>> versions along the Win9x and WinNT lines is another possibility, but
>>> it'll take a bit of work to determine how the #ifs should be converted.
>>
>> It's possible to use 'static if', now that it works at module scope.
>>
>> #if (WINVER > 0x4000)
>> #else
>> #endif
>> can become
>> static if (WINVER> 0x4000) {
>> } else {
>> }
>>
>> It's probably abuse of 'static if', but it should work as an interim
>> solution.
>
> Where would the user set WINVER? A module for the user to edit to
> supply this data might be one possibility, but it would be a nightmare
> for someone maintaining or even trying to compile several projects that
> have different OS requirements. But for as long as it's only an interim
> solution....
> It would also be nice if the policy for using the versions is clearer
> than the WINVER/_WIN32_WINDOWS/_WIN32_WINNT stuff is at the moment. At
> the moment, I'm puzzled by the number of instances of this
>
> #if (_WIN32_WINDOWS >= 0x0410 || _WIN32_WINNT >= 0x0500)
>
> or similar. It seems to be saying that the function may be used by
> either an application that supports Win98 or an application that
> supports Win2000. So you could have a program that works on Windows 98
> and Windows NT4 but not Windows 95, or a program that works on Windows
> 95 and Windows 2000 but not Windows NT4, and whatever is in that #if
> would be available to either. Unless I'm misunderstanding, it would
> appear that the || should be an &&.
To quote windef.h:
----------------------
#ifndef WINVER
#define WINVER 0x0400
/*
* If you need Win32 API features newer the Win95 and WinNT then you must
* define WINVER before including windows.h or any other method of
including
* the windef.h header.
*/
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT WINVER
/*
* There may be the need to define _WIN32_WINNT to a value different from
* the value of WINVER. I don't have any example of why you would do that.
* However, if you must then define _WIN32_WINNT to the value required
before
* including windows.h or any other method of including the windef.h
header.
*/
#endif
----------------
My conclusion -- Seems stupid to me, I bet this is historical. Since D
doesn't need to support 1990's legacy D code, we should be able to clean
it up.
More information about the Digitalmars-d-announce
mailing list