[완료] dereferencing pointer to incomplete type 에러 잡기
글쓴이: russell / 작성시간: 수, 2010/07/07 - 2:29오전
안녕하세요. 컴파일 중에 다음과 같은 에러가 나면서...일을 진행을 못 하고 있습니다.
cc -Wall -O3 -g -I../include -c -o net.o net.c net.c: In function ‘send_icmp’: net.c:92: error: dereferencing pointer to incomplete type net.c:105: error: dereferencing pointer to incomplete type net.c:108: error: dereferencing pointer to incomplete type net.c:109: error: dereferencing pointer to incomplete type net.c:92: warning: unused variable ‘cbuf’ make[1]: *** [net.o] Error 1
아래의 코드는 해당하는 함수 부분입니다.
88 send_icmp(struct sbuff *b, struct sockaddr_in6 *sin, int ifidx)
89 {
90 struct iovec iov = { b->head, b->len };
91 struct in6_pktinfo *ipi;
92 uint8_t cbuf[CMSG_SPACE(sizeof (*ipi))];
93 struct cmsghdr *cmsg = (struct cmsghdr *)cbuf;
94 struct msghdr msg = {
95 .msg_name = sin,
96 .msg_namelen = sizeof (*sin),
97 .msg_iov = &iov,
98 .msg_iovlen = 1,
99 .msg_control = cbuf,
100 .msg_controllen = sizeof (cbuf),
101 };
102
103 cmsg->cmsg_level = IPPROTO_IPV6;
104 cmsg->cmsg_type = IPV6_PKTINFO;
105 cmsg->cmsg_len = CMSG_LEN(sizeof (*ipi));
106
107 ipi = (struct in6_pktinfo *)CMSG_DATA(cmsg);
108 memset(ipi, 0, sizeof (*ipi));
109 ipi->ipi6_ifindex = ifidx;
110
111 DBG(&dbg, "sending %d bytes to %s (%d)", b->len,
112 inet_ntop(AF_INET6, &sin->sin6_addr, abuf, sizeof (abuf)),
113 ifidx);
114
115 if (sendmsg(icmp6sock, &msg, 0) < 0) {
116 DBG(&dbg_snd, "sendmsg: %s", strerror(errno));
117 return (-1);
118 }
119 return (0);
120 }문제가 있는 부분은 모두 91번째 라인에 있는 struct in6_pktinfo *ipi; 이 부분과 관련 된 것 같은데요. 도져히 못 잡아 내겠습니다. 인클루딩 했던 헤더들은 아래와 같아요.
33 #include <sys/param.h> 34 #include <sys/types.h> 35 #include <sys/socket.h> 36 37 #include <arpa/inet.h> 38 39 #include <net/if.h> 40 #include <net/route.h> 41 42 #include <netinet/in.h> 43 44 #include <errno.h> 45 #include <stdio.h> 46 #include <string.h> 47 #include <unistd.h>
Forums:


위 에러는
위 에러는 포인터형을 참조해서 실제 데이터를 보려고 하는데,
그 데이터형의 크기를 알 수 없을때 발생합니다.
struct in6_pktinfo 이 정의된 부분을 찾아보세요.
이름으로 봐선 왠지 linux/net/*.h 중에 들어있을 것 같네요.
언제나 삽질 - http://tisphie.net/typo/
프로그래밍 언어 개발 - http://langdev.net
언제나 삽질 - http://tisphie.net/typo/
프로그래밍 언어 개발 - http://langdev.net
예. 저도 그게
예. 저도 그게 의심스러워서요. 그래서 struct in6_pktinfo 이 정의 되어 있는 netinet/in.h 파일을 인클루드 시켰거든요. ㅠㅠ 으흠. 뭔가 다른것을 더 해야 할까요?
#ifdef __USE_GNU /* IPv6
#ifdef __USE_GNU /* IPv6 packet information. */ struct in6_pktinfo { struct in6_addr ipi6_addr;]./* src/dst IPv6 address */ unsigned int ipi6_ifindex;]./* send/recv interface index */ };이리 된걸보니
를 include 하기 전에 써줘야겠네요.
언제나 삽질 - http://tisphie.net/typo/
프로그래밍 언어 개발 - http://langdev.net
언제나 삽질 - http://tisphie.net/typo/
프로그래밍 언어 개발 - http://langdev.net
아! 그걸 이제야
아! 그걸 이제야 확인을 하고 무사히 컴파일을 했습니다! 감사합니다!
댓글 달기