This project is read-only.

VFP2C32 - Bit Fields in structures

Topics: Enhancement Request
Feb 28, 2013 at 10:25 PM
Hi Christian, I recently had to use the SetCommState Windows API function, one of the parameters is a DCB structure:
typedef struct _DCB {
  DWORD DCBlength;
  DWORD BaudRate;
  DWORD fBinary  :1;
  DWORD fParity  :1;
  DWORD fOutxCtsFlow  :1;
  DWORD fOutxDsrFlow  :1;
  DWORD fDtrControl  :2;
  DWORD fDsrSensitivity  :1;
  DWORD fTXContinueOnXoff  :1;
  DWORD fOutX  :1;
  DWORD fInX  :1;
  DWORD fErrorChar  :1;
  DWORD fNull  :1;
  DWORD fRtsControl  :2;
  DWORD fAbortOnError  :1;
  DWORD fDummy2  :17;
  WORD  wReserved;
  WORD  XonLim;
  WORD  XoffLim;
  BYTE  ByteSize;
  BYTE  Parity;
  BYTE  StopBits;
  char  XonChar;
  char  XoffChar;
  char  ErrorChar;
  char  EofChar;
  char  EvtChar;
  WORD  wReserved1;
Using vfp2c32front, I created the structure class. Testing the SetCommState function with this structure, it failed everytime.

After some reading, I learned about Bit Fields:

And in the case of the DCB structure:

So vfp2c32front was assigning 80 bytes to the structure instead of 28 bytes, because it does not handle bit fields.

So, is there any way to add support for bitfields in vfp2c32front ?

I suppose support will also have to be added to vfp2c32 to read and write to bitfields.

I think this is not really something very important to have, but just wanted to let you know of this issues.

I solved the problem of configuring the serial ports using BuildCommDCB.