Accessing the COMSTAT Structure
The Windows 3.x declaration of the COMSTAT structure is incompatible with ANSI standards. WINDOWS.H now defines the COMSTAT structure, for compatibility with ANSI compilers, so that the /W4 option does not issue warnings.
To support backward compatibility of source code, WINDOWS.H does not use the new structure definition unless the version of Windows (as indicated by WINVER) is 3.x or later, or if STRICT is defined. When you enable STRICT, the presumption is that you are trying to write portable code. Therefore, WINDOWS.H uses the new COMSTAT structure for all versions of Windows if STRICT is enabled.
The new structure definition replaces the bit fields with flags that access bits in a single field, named status, as shown in the following table. Each flag turns on a different bit.
Windows 3.x field name | Flag accessing the status field |
fCtsHold | CSTF_CTSHOLD |
fDsrHold | CSTF_DSRHOLD |
fEof | CSTF_EOF |
fRlsdHold | CSTF_RLSDHOLD |
fTxim | CSTF_TXIM |
fXoffHold | CSTF_XOFFHOLD |
fXoffSent | CSTF_XOFFSENT |
If your code accesses any of these status fields, you need to change your code as appropriate. For example, suppose you have the following code written for Windows 3.x:
if (comstat.fEof || fCondition)
comstat.fCtsHold = TRUE;
comstat.fTxim = FALSE;
This code should be replaced by code that accesses individual bits of the status field by using flags. Note the use of bitwise operators:
if ((comstat.status & CSTF_EOF) || fCondition)
comstat.status |= CSTF_CTSHOLD;
comstat.status &= ~CSTF_TXIM;