LinuxSir.cn,穿越时空的Linuxsir!

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

关于utmp的代码编译不过去

[复制链接]
发表于 2005-1-11 11:13:54 | 显示全部楼层 |阅读模式
以下代码使用gcc 编译不过去请哪位说说哪里错误

  1. #include <stdio.h>
  2. #include <utmp.h>
  3. #include <fcntl.h>
  4. #include <unistd.h>

  5. #define SHOWHOST
  6. void show_info(struct utmp * utbufp);
  7.   
  8.   int main()
  9. {
  10.    struct utmp current_record;
  11.    int utmpfd;
  12.    int reclen=sizeof(current_record);
  13.    if((utmpfd=open(UTMP_FILE,0_RDONLY))== -1)
  14.      {
  15.         perror(UTMP_FILE);
  16.         exit(1);
  17.      }
  18.    while(read(utmpfd,&current_record,reclen)==reclen)
  19.      show_line(&current_record);
  20.    close(utmptd);
  21.    return 0;
  22. }
  23. void show_info(struct utmp * utbufp)
  24. {
  25.    printf("%-8.8s",utbufp->ut_name);
  26.    printf(" ");
  27. }
复制代码
:help
发表于 2005-1-11 11:19:42 | 显示全部楼层
你贴个编译信息吧。
发表于 2005-1-11 12:38:08 | 显示全部楼层
呵呵,楼主是要找个人工的编译器呀,与gcc相比,这绝对是成本高、效率低。
发表于 2005-1-11 19:03:22 | 显示全部楼层
Post by doubleelec
呵呵,楼主是要找个人工的编译器呀,与gcc相比,这绝对是成本高、效率低。

这和楼主的程序有什么关系?
doubleelec兄是不是发错贴了?
发表于 2005-1-12 09:06:45 | 显示全部楼层
我的意思是说,楼主没有贴住编译时的信息,让别人用眼睛扫描源代码检查出那里有错误,这不是让人充当编译器嘛。
 楼主| 发表于 2005-1-12 12:18:36 | 显示全部楼层
对不起,错误信息如下:
cd '/root/testhello/debug/src' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" gmake -k testhello
compiling testhello.c (gcc)
/root/testhello/src/testhello.c:34: underscore in number
*** Exited with status: 2 ***
34行为 if((utmpfd=open(UTMP_FILE,0_RDONLY))== -1) 这一行
发表于 2005-1-12 12:30:20 | 显示全部楼层
Post by tonyking
对不起,错误信息如下:
cd '/root/testhello/debug/src' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" gmake -k testhello
compiling testhello.c (gcc)
/root/testhello/src/testhello.c:34: underscore in number
*** Exited with status: 2 ***
34行为 if((utmpfd=open(UTMP_FILE,0_RDONLY))== -1) 这一行


注意红色的地方第一个字符应该是大写的 O (欧),不是0(零)
 楼主| 发表于 2005-1-12 12:30:27 | 显示全部楼层
谢谢各位已经解决,O打成0
发表于 2005-1-12 14:34:49 | 显示全部楼层
Post by doubleelec
我的意思是说,楼主没有贴住编译时的信息,让别人用眼睛扫描源代码检查出那里有错误,这不是让人充当编译器嘛。

呵呵,原来如此!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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