#1617 Wrong Windows version check for AttachConsole

closed-invalid
nobody
2012-01-15
2012-01-15
izt
No

In the header wincon.h, the following line is preventing the use of AttachConsole on Windows 7 for no reason:

#if (_WIN32_WINNT >= 0x0501)

gcc version 3.4.5 (mingw-vista special r3)

The whole block:

#if (_WIN32_WINNT >= 0x0501)
#define ATTACH_PARENT_PROCESS ((DWORD)-1)
BOOL WINAPI AttachConsole(DWORD);
#endif

Discussion

  • Keith Marshall
    Keith Marshall
    2012-01-15

    • status: open --> closed-invalid
     
  • Keith Marshall
    Keith Marshall
    2012-01-15

    This is YOUR error, NOT a w32api bug. Furthermore, this is the second bogus bug report I have closed in as many weeks, relating to a user -- you in this case -- failing to define WINVER correctly.

    The correct definition of WINVER has NOTHING WHATSOEVER to do with the version of windows you might be running the compiler on -- I'm guessing Windows-7 in your case. I'ts purpose is to allow YOU to specify a MINIMUM version on which you want your application to run. If you don't specify otherwise, the current w32api version assumes you may want to support users on Win9x, so the guard is correct -- you can't use AttachConsole() and support 9x, so the compiler is correctly telling you this. It is YOUR choice to make, if you want to restrict your application to WinXP and later, (which is required for AttachConsole() -- and it is YOUR responsibility to define WINVER accordingly.

    FWIW, v3.18 of w32api will change the DEFAULT level of support to assume Win2K; you will STILL need to define WINVER to WinXP for AttachConsole(); you will ALSO need to set it back to 0x0400, if you want to guarantee Win9x support.