error: dereferencing pointer to incomplete type in C
I am getting following compilation errors in gcc. Anyone please help me in finding what is wrong?
$ gcc -c recv_v4.c recv_v4.c: In function `recv_v4': recv_v4.c:42: error: dereferencing pointer to incomplete type recv_v4.c:42: error: `ICMP_TIMXCEED' undeclared (first use in this function) recv_v4.c:42: error: (Each undeclared identifier is reported only once recv_v4.c:42: error: for each function it appears in.) recv_v4.c:42: error: dereferencing pointer to incomplete type recv_v4.c:42: error: `ICMP_TIMXCEED_INTRANS' undeclared (first use in this function) recv_v4.c:59: error: dereferencing pointer to incomplete type recv_v4.c:59: error: `ICMP_UNREACH' undeclared (first use in this function) recv_v4.c:72: error: dereferencing pointer to incomplete type recv_v4.c:72: error: `ICMP_UNREACH_PORT' undeclared (first use in this function) recv_v4.c:75: error: dereferencing pointer to incomplete type recv_v4.c:82: error: dereferencing pointer to incomplete type recv_v4.c:82: error: dereferencing pointer to incomplete type Following is the code: Code:
#include "trace.h" Code:
#include <sys/socket.h> |
I have tried and worked for me. So I suggest you to type gcc -E rec_v4.c > rec_v4.i and look at that rec_v4.i file, maybe it will give you a tip where is it lost. I do not know what os you have, maybe a define solves it.
|
I am using CYGWIN and Windows XP Professional OS.
|
In my <netinet/ip_icmp.h> you need to have __USE_BSD defined to get struct icmp and the macros you're using.
Kevin Barry |
I defined __USE_BSD in ip_icmp.h. But still having same errors.
|
Oh, no! Do not touch that file. gcc -D__USE_BSD -c recv_v4.c would be the way, but actually I cannot check if it solves your problem.
|
thanks pan64.
|
Quote:
Kevin Barry |
error: dereferencing pointer to incomplete type
i am working on my client/server chat program and i get "error: dereferencing pointer to incomplete type" when i compile my client.c.
Here is my code: #include <stdio.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/types.h> #include <string.h> #include <stdlib.h> #include <netdb.h> #include <unistd.h> #include <signal.h> #include <time.h> int main(int argc,char *argv[]) { struct sockaddr_in clientaddr; pid_t pid; int clientfd,sendbytes; struct hostent *host; char *buf,*buf_r; if(argc < 4) { printf("usage:\n"); printf("%s host port name\n",argv[0]); exit(1); } host = gethostbyname(argv[1]); if((clientfd = socket (AF_INET,SOCK_STREAM,0)) == -1) { perror("socket\n"); exit(1); } clientaddr.sin_family = AF_INET; clientaddr.sin_port = htons((uint16_t)atoi(argv[2])); clientaddr.sin_addr = *((struct in_addrr *) host->h_addr); bzero(&(clientaddr.sin_zero),0); if(connect(clientfd,(struct sockaddr *)&clientaddr,sizeof(struct sockaddr)) == -1) { perror("connect\n"); exit(1); } buf=(char *)malloc(120); memset(buf,0,120); buf_r=(char *)malloc(100); if( recv(clientfd,buf,100,0) == -1) { perror("recv: "); exit(1); } printf("\n%s\n",buf); pid = fork(); while(1) { if(pid > 0) { //get_cur_time(time_str); strcpy(buf,argv[3]); strcat(buf,":"); memset(buf_r,0,100); //gets(buf_r); fgets(buf_r,100,stdin); strncat(buf,buf_r,strlen(buf_r)-1); //strcat(buf,time_str); //printf("---%s\n",buf); if((sendbytes = send(clientfd,buf,strlen(buf),0)) == -1) { perror("send\n"); exit(1); } } else if(pid == 0) { memset(buf,0,1000); if(recv(clientfd,buf,100,0) <=0) { perror("recv:"); close(clientfd); raise(SIGSTOP); exit(1); } printf("%s\n",buf); } else perror("fork"); } close(clientfd); return 0; } Please help me find solution for this. Thank you. |
please open a new thread for your problem and also please use [code]here comes your code[/code] to keep formatting, and post the full error message.
Actually the real error message was: Quote:
clientaddr.sin_addr = *((struct in_addrr *) host->h_addr); so, just remove that r |
All times are GMT -5. The time now is 01:20 AM. |