Incidencia #38187

update wincon.h

Abrir Fecha: 2018-04-11 17:21 Última actualización: 2018-10-30 08:53

Informador:
Propietario:
Estado:
Cerrado
Componente:
Hito:
(Ninguno)
Prioridad:
5 - Medium
Gravedad:
5 - Medium
Resolución:
Fixed
Fichero:
3
Vote
Score: 1
100.0% (1/1)
0.0% (0/1)

Details

The current one seems very outdated.

It misses some older things (I was told that this is around since 2007) like the CONSOLE_SCREEN_BUFFER_INFOEX structure

  1. typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
  2. ULONG cbSize;
  3. COORD dwSize;
  4. COORD dwCursorPosition;
  5. WORD wAttributes;
  6. SMALL_RECT srWindow;
  7. COORD dwMaximumWindowSize;
  8. WORD wPopupAttributes;
  9. BOOL bFullscreenSupported;
  10. COLORREF ColorTable[16];
  11. } CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;

and the newer COMMON_LVB_ defines for CHAR_INFO structure such as

  1. #ifndef COMMON_LVB_GRID_HORIZONTAL
  2. #define COMMON_LVB_GRID_HORIZONTAL 0x0400 /* Top horizontal */
  3. #endif
  4. #ifndef COMMON_LVB_GRID_LVERTICAL
  5. #define COMMON_LVB_GRID_LVERTICAL 0x0800 /* Left vertical */
  6. #endif
  7. #ifndef COMMON_LVB_GRID_RVERTICAL
  8. #define COMMON_LVB_GRID_RVERTICAL 0x1000 /* Right vertical */
  9. #endif
  10. #ifndef COMMON_LVB_REVERSE_VIDEO
  11. #define COMMON_LVB_REVERSE_VIDEO 0x4000 /* Reverse foreground and background attribute */
  12. #endif
  13. #ifndef COMMON_LVB_UNDERSCORE
  14. #define COMMON_LVB_UNDERSCORE 0x8000 /* Underscore */
  15. #endif

Note: all these are included in mingw-w64 since some time but I think the original should be updated, too :-)

Ticket History (3/15 Histories)

2018-04-11 17:21 Updated by: osdn-mensch
  • New Ticket "update wincon.h" created
2018-04-12 01:19 Updated by: keith
  • Details Updated
Comentario

Yes, it would be useful to add these; I guess no one has been sufficiently interested to submit either a patch, or even a feature request, until now.

I note that the Microsoft docs indicate that struct _CONSOLE_SCREEN_BUFFER_INFOEX requires Vista, or later, but they have been notoriously dishonest about minimum required versions, in the past. Do you happen to know if Vista is a genuine minimum requirement, in this case? Or, must we just take this on faith?

In the case of the struct CHAR_INFO documentation, we actually see an example of Microsoft's dishonesty, for this structure has been supported since Win95, and the earliest versions of WinNT, whereas Microsoft's docs now claim that it requires Win2K or later. However, the COMMON_LVB_* attribute defines, to which you refer, were not supported from the outset; do you happen to know what version of Windows introduced them?

Do note that definitions in the form that you suggest, e.g.

  1. #ifndef COMMON_LVB_GRID_HORIZONTAL
  2. #define COMMON_LVB_GRID_HORIZONTAL 0x0400 /* Top horizontal */
  3. #endif
are fundamentally wrong, because:

  1. If the attribute is defined elsewhere, then the enclosing #if guard denies the compiler any opportunity to check consistency, and
  2. If the attribute is not defined elsewhere, (as it really should not be), then the #if guard is entirely redundant.

I note that Microsoft also documents:

  1. #define COMMON_LVB_LEADING_BYTE 0x0100
  2. #define COMMON_LVB_TRAILING_BYTE 0x0200
(which you don't mention). These are also missing from our <wincon.h>; I guess it would be appropriate to add them too.

2018-04-12 03:54 Updated by: osdn-mensch
Comentario

Do you happen to know if Vista is a genuine minimum requirement, in this case? Or, must we just take this on faith?

I'd personally just ignore the "minimum version part". I guess you want to surround this by NT version number check, correct? Just checked Win10 SDK - only surrounds CONSOLE_SCREEN_BUFFER_INFOEX by "not phone" (the COMMON_LVB_ attributes are not surrounded and I assume they just don't do anything on Win95/Win2k)

Note: cmd replacements like ConEmu may support these on older OS versions, too.

Do note that definitions in the form that you suggest, e.g. are fundamentally wrong, because ...

People may have defined these themselves - but it is unlikely that this happens before including wincon.h (or windows.h). The code was put in place in an application expecting these values when MINGW is used (this obviously only was tested on mingw-w64 which has them in since a while) and I haven't seen a quick way to distinguish these environments. I'd also say the ifdefs should *not* be included in wincon.h.

I note that Microsoft also documents ... which you don't mention.

Yes, adding these would be good (the application just didn't used them).WIN10 SDK ships even more:

  1. #define COMMON_LVB_LEADING_BYTE 0x0100 // Leading Byte of DBCS
  2. #define COMMON_LVB_TRAILING_BYTE 0x0200 // Trailing Byte of DBCS
  3. #define COMMON_LVB_GRID_HORIZONTAL 0x0400 // DBCS: Grid attribute: top horizontal.
  4. #define COMMON_LVB_GRID_LVERTICAL 0x0800 // DBCS: Grid attribute: left vertical.
  5. #define COMMON_LVB_GRID_RVERTICAL 0x1000 // DBCS: Grid attribute: right vertical.
  6. #define COMMON_LVB_REVERSE_VIDEO 0x4000 // DBCS: Reverse fore/back ground attribute.
  7. #define COMMON_LVB_UNDERSCORE 0x8000 // DBCS: Underscore.
  8. #define COMMON_LVB_SBCSDBCS 0x0300 // SBCS or DBCS flag.
(Edited, 2018-04-12 03:55 Updated by: osdn-mensch)
2018-08-03 06:45 Updated by: keith
  • File wincon-updates.patch (File ID: 5416) is attached
2018-08-13 21:24 Updated by: keith
Comentario

Reply To osdn-mensch

Do you happen to know if Vista is a genuine minimum requirement, in this case? Or, must we just take this on faith?

I'd personally just ignore the "minimum version part". I guess you want to surround this by NT version number check, correct?

Yes.

Just checked Win10 SDK - only surrounds CONSOLE_SCREEN_BUFFER_INFOEX by "not phone" (the COMMON_LVB_ attributes are not surrounded and I assume they just don't do anything on Win95/Win2k)

I wouldn't be too confident about that: normal behaviour of Microsoft APIs is to crash, when passed a flag which they don't understand ... even if the flag may be defined for a later version of the API. My concern is that exposing new flags, unconditionally, may lead to unexpected run-time application crashes, on legacy OS versions, where an appropriate #if guard block could catch the potential for crashing, at compile time. We need to either accept the Microsoft documentation at face value, or we need to devise a test for safety of such flags on legacy OS versions ... and to find testers who can run that test on a multitude of legacy Win32 versions.

Note: cmd replacements like ConEmu may support these on older OS versions, too.

Really? Even if the supporting API isn't provided by the underlying (legacy) OS version? That would imply that ConEmu, (or other terminal emulator), provides its own fall-back emulation of such APIs: not impossible, but by no means a trivial task; seems kind of improbable.

Also note: ConEmu is not a cmd replacement; cmd.exe is a shell; AIUI, ConEmu is a terminal emulator ... a container in which a shell is run, (and that shell may well be cmd.exe).

(Edited, 2018-08-13 21:27 Updated by: keith)
2018-08-13 22:25 Updated by: keith
Comentario

This official Microsoft documentation page indicates that the COMMON_LVB attributes are supported from Win2K onwards. This unofficial legacy documentation page does not mention them, which suggests that they may not have been supported prior to Win2K.

Certainly, this is an opinion based on conjecture, but I think it may be appropriate to place these definitions within an #if _WIN32_WINNT >= _WIN32_WINNT_WIN2K exposure guard block.

2018-08-13 22:40 Updated by: keith
  • File wincon-self-contained.patch (File ID: 5420) is attached
2018-08-14 00:09 Updated by: osdn-mensch
Comentario

.. @keith - Do we have something to commit now?

2018-08-14 01:01 Updated by: keith
Comentario

Reply To osdn-mensch

.. @keith - Do we have something to commit now?

No. I now have three patches, but I'm not yet entirely satisfied with them. Specifically:

  1. _WIN32_WINNT specific symbol visibility guards are inadequately defined; many symbols are visible to compilations for legacy Windows versions, for which they may not be applicable.
  2. Bit-flag values should be specified in hexadecimal -- as Microsoft do in their on-line documentation -- not in decimal, as they are at present, in our <wincon.h>; this may make no difference to the compiler, but it is sub-optimal for human interpretation.

I'm working on it, but I'll need a few more days to finalize it. In the meantime, you're welcome to try the two patches I've attached so far. My third patch will be more significant; it already addresses item (2), but not yet (1). I will not publish it, until I've dealt with that, by which time the series of three should be ready to commit.

FTR, the lack of a formal ChangeLog entry, to accompany David Gressett's initial patch, will introduce a delay ... because I will have to write it for him.

2018-08-14 22:48 Updated by: keith
  • File wincon-updates.patch (File ID: 5416) is deleted
2018-08-14 22:51 Updated by: keith
  • File wincon-self-contained.patch (File ID: 5420) is deleted
2018-10-30 08:53 Updated by: keith
  • Resolución Update from Ninguno to Fixed
  • Propietario Update from (Ninguno) to keith
  • Estado Update from Open to Cerrado
Comentario

I've pushed the changes, as discussed, to the git repository; they will be incorporated into the upcoming wsl-5.2 release.

Attachment File List

  • wincon-updates.patch(13KB)
    • David Gressett's <wincon.h> patch (updated)
  • wincon-self-contained.patch(1KB)
    • Trivial extension to David Gressett's patch, to ensure that <windef.h> or <wingdi.h> is included.
  • wincon-cleanup.patch(28KB)
    • Revision of updated <wincon.h>, to improve layout, consolidate version dependent definition groups, and express bit-flag constants more logically

Editar

Please login to add comment to this ticket » Entrar