What is the Windows equivalent to the capabilities defined in sys/select.h and termios.h

后端 未结 2 540
梦如初夏
梦如初夏 2020-11-27 18:17

I have an application in linux, which is compiled successfully. I want to run the same program in windows.

But compilation produces the following errors related to h

2条回答
  •  爱一瞬间的悲伤
    2020-11-27 19:01

    I created 2 files using code I found in some forums to circumvent windows.h and windows com port libraries:

    "nowindows.h"

    /* file nowindows.h v1.0 use at your own risk *
    #ifndef DWORD
    #define WINAPI
    typedef unsigned long DWORD;
    typedef short WCHAR;
    typedef void * HANDLE;
    #define MAX_PATH PATH_MAX
    typedef unsigned char BYTE;
    typedef unsigned short WORD;
    typedef unsigned int BOOL;
    #include 
    #include 
    #include "unistd.h"
    #include 
    
    #define GENERIC_READ                O_RDONLY    //read only mode
    #define GENERIC_WRITE               O_WRONLY    //write only mode
    #define CREATE_ALWAYS               O_CREAT     //create new file
    #define OPEN_EXISTING               0           //fake parameter's value
    #define FILE_ATTRIBUTE_NORMAL       0644        // file attributes
    #endif
    

    and

    "nowindowscomport.h"

    /* file nowindowscomport.h v1.0 use at your own risk *//
    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;
    } DCB, *LPDCB;
    typedef struct _COMSTAT {
        DWORD fCtsHold  :1;
        DWORD fDsrHold  :1;
        DWORD fRlsdHold  :1;
        DWORD fXoffHold  :1;
        DWORD fXoffSent  :1;
        DWORD fEof  :1;
        DWORD fTxim  :1;
        DWORD fReserved  :25;
        DWORD cbInQue;
        DWORD cbOutQue;
    } COMSTAT, *LPCOMSTAT;
    typedef struct _COMMTIMEOUTS {
        DWORD ReadIntervalTimeout;
        DWORD ReadTotalTimeoutMultiplier;
        DWORD ReadTotalTimeoutConstant;
        DWORD WriteTotalTimeoutMultiplier;
        DWORD WriteTotalTimeoutConstant;
    } COMMTIMEOUTS, *LPCOMMTIMEOUTS;
    #define ERROR_INVALID_HANDLE             6L 
    /* Purge functions for Comm Port */
    #define PURGE_TXABORT       0x0001  /* Kill pending/current @@-377,11 +382,4 @@ */
    #define PURGE_RXCLEAR 0x0008
    #define PURGE_TXCLEAR 0x0004
    #define PURGE_RXABORT 0x0002
    // DTR Control Flow Values.
    #define DTR_CONTROL_DISABLE    0x00
    #define DTR_CONTROL_ENABLE     0x01
    #define DTR_CONTROL_HANDSHAKE  0x02
    #define RTS_CONTROL_DISABLE 0x00
    #define NOPARITY 0
    #define ONESTOPBIT 0
    

提交回复
热议问题