搞不懂:
typedef struct _DCB { 
  DWORD DCBlength;           // sizeof(DCB) 
  DWORD BaudRate;            // current baud rate 
  DWORD fBinary: 1;          // binary mode, no EOF check 
  DWORD fParity: 1;          // enable parity checking 
  DWORD fOutxCtsFlow:1;      // CTS output flow control 
  DWORD fOutxDsrFlow:1;      // DSR output flow control 
  DWORD fDtrControl:2;       // DTR flow control type 
  DWORD fDsrSensitivity:1;   // DSR sensitivity 
  DWORD fTXContinueOnXoff:1; // XOFF continues Tx 
  DWORD fOutX: 1;          // XON/XOFF out flow control 
  DWORD fInX: 1;           // XON/XOFF in flow control 
  DWORD fErrorChar: 1;     // enable error replacement 
  DWORD fNull: 1;          // enable null stripping 
  DWORD fRtsControl:2;     // RTS flow control 
  DWORD fAbortOnError:1;   // abort on error 
  DWORD fDummy2:17;        // reserved 
  WORD wReserved;          // not currently used 
  WORD XonLim;             // transmit XON threshold 
  WORD XoffLim;            // transmit XOFF threshold 
  BYTE ByteSize;           // number of bits/byte, 4-8 
  BYTE Parity;             // 0-4=no,odd,even,,space 
  BYTE StopBits;           // 0,1,2 = 1, 1.5, 2 
  char XonChar;            // Tx and Rx XON character 
  char XoffChar;           // Tx and Rx XOFF character 
  char ErrorChar;          // error replacement character 
  char EofChar;            // end of input character 
  char EvtChar;            // received event character 
  WORD wReserved1;         // reserved; do not use 
} DCB; 如果按28字节来算,那么从fBinary至fDummy2才占了四个字节,不过依定义这显然是不对的

解决方案 »

  1.   

    一串后面有“:”的,“:”后的数表示bit,加起来再除以8,共为4字节。所以全体是28字节
      DWORD fBinary: 1;          // binary mode, no EOF check 
      DWORD fParity: 1;          // enable parity checking 
      DWORD fOutxCtsFlow:1;      // CTS output flow control 
      DWORD fOutxDsrFlow:1;      // DSR output flow control 
      DWORD fDtrControl:2;       // DTR flow control type 
      DWORD fDsrSensitivity:1;   // DSR sensitivity 
      DWORD fTXContinueOnXoff:1; // XOFF continues Tx 
      DWORD fOutX: 1;          // XON/XOFF out flow control 
      DWORD fInX: 1;           // XON/XOFF in flow control 
      DWORD fErrorChar: 1;     // enable error replacement 
      DWORD fNull: 1;          // enable null stripping 
      DWORD fRtsControl:2;     // RTS flow control 
      DWORD fAbortOnError:1;   // abort on error 
      DWORD fDummy2:17;        
      

  2.   

    sizeof(DWORD) = 4
    sizeof(WORD)  = 2
    sizeof(BYTE)  = 1
    sizeof(char)  = 1以f开头的只占指定的位数,如:
    struct CELL             // Declare CELL bit field
    {
       unsigned character  : 8;  // 00000000 ????????
       unsigned foreground : 3;  // 00000??? 00000000
       unsigned intensity  : 1;  // 0000?000 00000000
       unsigned background : 3;  // 0???0000 00000000
       unsigned blink      : 1;  // ?0000000 00000000
    } screen[25][80];       // Array of bit fields 所以:
    {
      DWORD fBinary: 1;          // binary mode, no EOF check 
      DWORD fParity: 1;          // enable parity checking 
      DWORD fOutxCtsFlow:1;      // CTS output flow control 
      DWORD fOutxDsrFlow:1;      // DSR output flow control 
      DWORD fDtrControl:2;       // DTR flow control type 
      DWORD fDsrSensitivity:1;   // DSR sensitivity 
      DWORD fTXContinueOnXoff:1; // XOFF continues Tx 
      DWORD fOutX: 1;          // XON/XOFF out flow control 
      DWORD fInX: 1;           // XON/XOFF in flow control 
      DWORD fErrorChar: 1;     // enable error replacement 
      DWORD fNull: 1;          // enable null stripping 
      DWORD fRtsControl:2;     // RTS flow control 
      DWORD fAbortOnError:1;   // abort on error 
      DWORD fDummy2:17;        // reserved 
    }
    只占4个bytes所以总数是:(4*3)+(2*4)+(1*8)=28 byte.