[FEEDBACK] Issue with fd_set, FD_ZERO, FD_SET, FD_SETSIZE : Cygwin
Yeo Kai Wei
yeokaiwei@hotmail.com
Mon Feb 6 20:33:53 GMT 2023
Hi All,
Thanks for the help.
I tried adding "#include <sys/select.h>".
However, this is the error message that was returned to me.
$ gcc -o selectStdIn selectStdIn.c
selectStdIn.c:9:10: fatal error: sys/select.h: No such file or directory
#include <sys/select.h>
Thank you.
On 7/2/2023 4:30 am, gs-cygwin.com@gluelogic.com wrote:
> On Tue, Feb 07, 2023 at 04:25:22AM +0800, Yeo Kai Wei via Cygwin wrote:
>> Hi,
>>
>> I would like to report an issue with Cygwin 3.4.2 on Windows.
>>
>> It doesn't seem to be able to work with fd_set, FD_ZERO, FD_SET, FD_SETSIZE
>> macros.
>>
>> The code is in italics. The filename was selectStdIn.c. The terminal command
>> used was "gcc -o selectStdIn selectStdIn.c"
>>
>> Thank you.
>>
>> /
>> /
>>
>> /CODE
>> /
>>
>> /#include <stdio.h>//
>> //#include <stdlib.h>//
>> //#include <sys/time.h>//
>> //#include <unistd.h>//
>> / /
>> //void main()//
>> //{//
>> // fd_set fds; //set of file descriptors//
>> / /
>> // struct timeval tv;//
>> / /
>> // int flag;//
>> / /
>> // char byte;//
>> / /
>> // FD_ZERO(&fds);//
>> / /
>> // FD_SET(0, &fds);//
>> / /
>> // tv.tv_sec = 5;//
>> / /
>> // tv.tv_usec = 0;//
>> / /
>> // flag = select(FD_SETSIZE, //
>> // &fds,//
>> // NULL,//
>> // NULL,//
>> // &tv);//
>> / /
>> // if(-1 == flag)//
>> // perror("select error");//
>> // else if(flag)//
>> // {//
>> // read(0,&byte,1);//
>> / /
>> // puts("data read");//
>> // }//
>> / /
>> // if(flag)//
>> // printf("The byte value is %c\n", byte);//
>> ////
>> //}/
>>
>>
>> TERMINAL COMMANDS
>>
>> $ gcc -o selectStdIn selectStdIn.c
>> selectStdIn.c: In function 'main':
>> selectStdIn.c:8:2: error: unknown type name 'fd_set'; did you mean 'fpos_t'?
>> fd_set fds; //set of file descriptors
>> ^~~~~~
>> fpos_t
>> selectStdIn.c:16:2: warning: implicit declaration of function 'FD_ZERO'
>> [-Wimpli
>> cit-function-declaration]
>> FD_ZERO(&fds);
>> ^~~~~~~
>> selectStdIn.c:18:2: warning: implicit declaration of function 'FD_SET'
>> [-Wimplic
>> it-function-declaration]
>> FD_SET(0, &fds);
>> ^~~~~~
>> selectStdIn.c:24:9: warning: implicit declaration of function 'select'; did
>> you
>> mean 'sleep'? [-Wimplicit-function-declaration]
>> flag = select(FD_SETSIZE,
>> ^~~~~~
>> sleep
>> selectStdIn.c:24:16: error: 'FD_SETSIZE' undeclared (first use in this
>> function)
>> flag = select(FD_SETSIZE,
>> ^~~~~~~~~~
>> selectStdIn.c:24:16: note: each undeclared identifier is reported only once
>> for
>> each function it appears in
> $ man select
>
> #include <sys/select.h>
More information about the Cygwin
mailing list