LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 747|回复: 4

检查daytimetcpcli.c有一大堆的错误??

[复制链接]
发表于 2004-4-8 15:47:55 | 显示全部楼层 |阅读模式
这是源程序:

  1. #include "unp.h"
  2. int
  3. main(int argc,char **argv)
  4. {
  5.     int                     sockfd,n;
  6.     char                    recvline[MAXLINE+1];
  7.     struct sockaddr_in      servaddr;
  8.     if(argc != 2) {
  9.           printf("Usage : %s <IPaddress>\n",argv[0]);
  10.           return(1);
  11.     }
  12.     if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0) {
  13.           printf("create socket error\n");
  14.           return(1);
  15.     }
  16.     bzero(&servaddr,sizeof(servaddr));
  17.     servaddr.sin_family=AF_INET;
  18.     servaddr.sin_port=htons(13);
  19.     if(inet_pton(AF_INET,argv[1],&servaddr.sin_addr) <= 0) {
  20.           printf("inet_pton error\n");
  21.           retrun(1);
  22.     }
  23.     if(connect(sockfd,(struct sockaddr *)&servaddr,sieof(servaddr))<0) {
  24.           printf("connect error\n");
  25.           return(1);
  26.     }
  27.     while((n=read(sockfd,recvline,MAXLINE))>0) {
  28.           recvline[n]=0;    /* null terminate */
  29.           if(fputs(recvline,stdout) == EOF ) {
  30.                  printf("fputs error\n");
  31.                  return(1);
  32.           }
  33.     }
  34.     if(n<0) {
  35.           printf("read error\n");
  36.           return(1);
  37.     }
  38.     return(0);
  39. }
复制代码

un.h我是照着书抄的,估计没问题。以下是错误。@@@@@@

  1. In file included from daytimetcpcli.c:1:
  2. /usr/include/unp.h:10: syntax error before `/'
  3. In file included from /usr/include/sys/inttypes.h:9,
  4.                  from /usr/include/sys/types.h:48,
  5.                  from /usr/include/unp.h:15,
  6.                  from daytimetcpcli.c:1:
  7. /usr/include/machine/ansi.h:146: syntax error before `__int64_t'
  8. In file included from /usr/include/sys/types.h:48,
  9.                  from /usr/include/unp.h:15,
  10.                  from daytimetcpcli.c:1:
  11. /usr/include/sys/inttypes.h:14: syntax error before `int64_t'
  12. /usr/include/sys/inttypes.h:14: warning: data definition has no type or storage class
  13. In file included from /usr/include/sys/types.h:49,
  14.                  from /usr/include/unp.h:15,
  15.                  from daytimetcpcli.c:1:
  16. /usr/include/machine/types.h:51: syntax error before `vm_ooffset_t'
  17. /usr/include/machine/types.h:51: warning: data definition has no type or storage class
  18. In file included from /usr/include/unp.h:15,
  19.                  from daytimetcpcli.c:1:
  20. /usr/include/sys/types.h:66: syntax error before `quad_t'
  21. /usr/include/sys/types.h:66: warning: data definition has no type or storage class
  22. /usr/include/sys/types.h:67: syntax error before `*'
  23. /usr/include/sys/types.h:67: warning: data definition has no type or storage class
  24. /usr/include/sys/types.h:82: syntax error before `off_t'
  25. /usr/include/sys/types.h:82: warning: data definition has no type or storage class
  26. /usr/include/sys/types.h:84: syntax error before `rlim_t'
  27. /usr/include/sys/types.h:84: warning: data definition has no type or storage class
  28. In file included from /usr/include/unp.h:15,
  29.                  from daytimetcpcli.c:1:
  30. /usr/include/sys/types.h:198: syntax error before `off_t'
  31. /usr/include/sys/types.h:202: syntax error before `lseek'
  32. /usr/include/sys/types.h:202: syntax error before `off_t'
  33. /usr/include/sys/types.h:202: warning: data definition has no type or storage class
  34. /usr/include/sys/types.h:206: syntax error before `off_t'
  35. /usr/include/sys/types.h:210: syntax error before `off_t'
  36. In file included from /usr/include/unp.h:16,
  37.                  from daytimetcpcli.c:1:
  38. /usr/include/sys/socket.h:191: syntax error before `int64_t'
  39. /usr/include/sys/socket.h:451: syntax error before `off_t'
  40. In file included from /usr/include/unp.h:17,
  41.                  from daytimetcpcli.c:1:
  42. /usr/include/sys/time.h:147: syntax error before `int64_t'
  43. In file included from /usr/include/unp.h:22,
  44.                  from daytimetcpcli.c:1:
  45. /usr/include/fcntl.h:181: syntax error before `off_t'
  46. In file included from /usr/include/unp.h:25,
  47.                  from daytimetcpcli.c:1:
  48. /usr/include/stdio.h:55: syntax error before `fpos_t'
  49. /usr/include/stdio.h:55: warning: data definition has no type or storage class
  50. /usr/include/stdio.h:110: syntax error before `fpos_t'
  51. /usr/include/stdio.h:127: syntax error before `fpos_t'
  52. /usr/include/stdio.h:207: syntax error before `fpos_t'
  53. /usr/include/stdio.h:217: syntax error before `*'
  54. /usr/include/stdio.h:306: syntax error before `__int64_t'
  55. /usr/include/stdio.h:307: syntax error before `ftello'
  56. /usr/include/stdio.h:307: warning: data definition has no type or storage class
  57. /usr/include/stdio.h:339: syntax error before `fpos_t'
  58. /usr/include/stdio.h:339: syntax error before `fpos_t'
  59. /usr/include/stdio.h:339: `funopen' declared as function returning a function
  60. In file included from /usr/include/unp.h:26,
  61.                  from daytimetcpcli.c:1:
  62. /usr/include/stdlib.h:186: syntax error before `strtoq'
  63. /usr/include/stdlib.h:186: warning: data definition has no type or storage class
  64. In file included from /usr/include/unp.h:28,
  65.                  from daytimetcpcli.c:1:
  66. /usr/include/sys/stat.h:99: syntax error before `off_t'
  67. /usr/include/sys/stat.h:105: syntax error before `int64_t'
  68. /usr/include/sys/stat.h:129: syntax error before `off_t'
  69. /usr/include/sys/stat.h:134: syntax error before `int64_t'
  70. In file included from /usr/include/unp.h:30,
  71.                  from daytimetcpcli.c:1:
  72. /usr/include/unistd.h:135: syntax error before `off_t'
  73. /usr/include/unistd.h:143: syntax error before `off_t'
  74. /usr/include/unistd.h:145: syntax error before `off_t'
  75. /usr/include/unistd.h:186: syntax error before `__syscall'
  76. /usr/include/unistd.h:186: syntax error before `...'
  77. /usr/include/unistd.h:186: warning: data definition has no type or storage class
  78. In file included from daytimetcpcli.c:1:
  79. /usr/include/unp.h:376: syntax error before `off_t'
复制代码

这一定在哪里出错里,要不然也不会错这么多阿。。。。。。:confused: :confused: :confused: :help
发表于 2004-4-8 19:15:13 | 显示全部楼层
还是好好检查一下unp.h有什么打字错误。
发表于 2004-4-8 20:27:08 | 显示全部楼层
是你自己的问题,试着不用老大给的函数,用自己的写个呢
发表于 2004-4-9 07:40:13 | 显示全部楼层

unp的问题

你是用的W.Richard.Stevens的unix programming 吧,他的unp头文件里面的函数分别实现在一些文件里面。
你用unp的话,要把那几个文件夹也放到你的user path里面去就好了。
 楼主| 发表于 2004-4-9 13:50:59 | 显示全部楼层
谢谢大家,原来是注释那里弄重复了/* /* some */*/

请问怎么得到config.h文件。我照着书去下载,不行哦。。:confused: :confused:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表