fd_set 관련 컴파일 문제 도움 요청드립니다.
글쓴이: baarong / 작성시간: 월, 2018/06/11 - 10:25오전
#include <stdio.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/signal.h> #include <sys/un.h> #include <unistd.h> #include <strings.h> #include <string.h> int wait_reply(fd, time_out) int fd; int time_out; { struct timeval t_val; struct fd_set fdset; int irv; t_val.tv_sec = time_out; t_val.tv_usec = 0; /* microtime 무시 */ FD_ZERO(&fdset); FD_SET(fd, &fdset); if (time_out < 0) { irv = select(fd+1, &fdset, NULL, NULL, NULL); } else { errno = 0; irv = select(fd+1, &fdset, NULL, NULL, &t_val); } return (irv); }
이런 구조의 소스를 컴파일 하는 과정에서 아래와 같은 오류가 발생하고 있습니다.
wrk_data_comm_lb.c: In function ‘wait_reply’: wrk_data_comm_lb.c:5148:25: error: storage size of ‘fdset’ isn’t known struct fd_set fdset; ^ make[1]: *** [wrk_data_comm_lb.o] 오류 1
제가 위에서 선언한 시스템 Header 중에서 sys/types.h 안에 sys/select.h 을 include 하게 되어있었고요. fd_set은 select.h 에서 선언이 되어있는 구조체였습니다.
-- types.h -- /* It also defines `fd_set' and the FD_* macros for `select'. */ # include <sys/select.h> -- select.h -- /* fd_set for select and pselect. */ typedef struct { /* XPG4.2 requires this member name. Otherwise avoid the name from the global namespace. */ #ifdef __USE_XOPEN __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS]; # define __FDS_BITS(set) ((set)->fds_bits) #else __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS]; # define __FDS_BITS(set) ((set)->__fds_bits) #endif } fd_set;
왜 재정의 부분에서 저런 오류가 뜨는 걸까요..ㅠ 도움 부탁드립니다.
Forums:
typedef struct { } fd_set 으로
typedef struct { } fd_set 으로 원형 선언되어 있으면
본문에서는 fd_set fdset; 이렇게 코딩하시면 됩니다. struct를 빼세요.
감사합니다.
앞의 struct를 제외하니 해결이 되었네요. 감사합니다.
댓글 달기