| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1560 人关注过本帖
标题:tuxedo中间件C程序 找不到错误,编译总语法错误,各位大虾帮找找
只看楼主 加入收藏
khaz
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:130
专家分:188
注 册:2011-4-21
结帖率:77.78%
收藏
已结贴  问题点数:18 回复次数:3 
tuxedo中间件C程序 找不到错误,编译总语法错误,各位大虾帮找找
程序目的是想通过命令行读取一个文件:
hwt 29 18677150924
lht 28 13398813422
csq 25 13234234564
以fml32格式发送到服务器,服务器返回结果会多一列:
hwt 29 18677150924 1
lht 28 13398813422 2
csq 25 13234234564 3
现在程序就是想发送后接收并打印结果。程序有点长,很多函数库可能大家不清楚,不过现在卡在C语言语法上了,编译不通过,而且我找了很久找不到原因,希望有强人能帮看看 谢谢!
程序代码:
#include <stdio.h>
#include <string.h>
#include "atmi.h"
#include "fml32.h"
#include "userlog.h"
#include "fmlfile.h"

struct tlr{
  char name[10];
  long age;
  char phone[12];
};

struct tlr2{
  char name[10];
  long age;
  char phone[12];
  long no;
};


int main(int argc, char *argv[])
{

  if(argc!=2){
        (void)fprintf(stderr,"usage:%s filename\n",argv[0]);
        (void)exit(1);
        }
  FBFR32 *pF32,*pF32rec;
  long len;
  FLDLEN32 len2;

  int counter,i,ret;
  FILE *fp;
  char *str1;

  if (tpinit((TPINIT *)NULL) == -1) {
    (void)fprintf(stderr, "Failed to join application  -- %s\n",
                  tpstrerror(tperrno));
    (void)userlog("Clientfml failed to join application  -- %s\n",
                  tpstrerror(tperrno));
    (void)exit(1);
  }

  if ((pF32 = (FBFR32 *)tpalloc("FML32", NULL, Fneeded32(1,30))) == NULL) {
    (void)fprintf(stderr, "Failure to allocate FML32 buffer -- %s\n",
                  tpstrerror(tperrno));
    (void)userlog("Clientfml failed to allocate FML32 buffer -- %s\n",
                  tpstrerror(tperrno));
    (void)tpterm();
    (void)exit(1);
  }

  if ((pF32rec = (FBFR32 *)tpalloc("FML32", NULL, Fneeded32(1,32))) == NULL) {
    (void)fprintf(stderr, "Failure to allocate FML32 buffer -- %s\n",
                  tpstrerror(tperrno));
    (void)userlog("Clientfml failed to allocate FML32 buffer -- %s\n",
                  tpstrerror(tperrno));
    (void)tpterm();
    (void)exit(1);
  }


 struct tlr ptlr[3];

 struct tlr2 ptlr2[3];
  fp=fopen(argv[1],"r");
  if(fp==NULL){
  (void)fprintf(stderr,"%s: file no found!\n",argv[1]);
  (void)exit(1);
  }

  while(fgets(str1,100,fp)!=NULL){
  if((ret=sscanf(str1, "%s %ld %s", ptlr[i].name, &ptlr[i].age, ptlr[i].phone))<3){
  (void)fprintf(stderr,"error in calling sscanf():%d\n",ret);
  (void)exit(1);
  }
  }

  for(i=0;i<3;i++){
    if (Fadd32(pF32,name, (char *)ptlr[i].name, 0) == -1) {
      (void)fprintf(stderr, "Failure to change name field -- %s\n",
                  Fstrerror32(Ferror32));
      (void)userlog("Clientfml failed to change name field -- %s\n",
                  Fstrerror32(Ferror32));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
    }

     if (Fadd32(pF32,age, (char *)&ptlr[i].age, 0) == -1) {
      (void)fprintf(stderr, "Failure to change age field -- %s\n",
                  Fstrerror32(Ferror32));
      (void)userlog("Clientfml failed to change age field -- %s\n",
                  Fstrerror32(Ferror32));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
    }

      if (Fadd32(pF32,phone, (char *)ptlr[i].phone, 0) == -1) {
      (void)fprintf(stderr, "Failure to change phone field -- %s\n",
                  Fstrerror32(Ferror32));
      (void)userlog("Clientfml failed to change phone field -- %s\n",
                  Fstrerror32(Ferror32));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
    }




  }
  if (tpcall("FMLTEST", (char *)pF32, 0, (char **)&pF32rec, &len,0) == -1) {
      (void)fprintf(stderr, "Failure to call the FMLTEST service -- %s \n",
                  tpstrerror(tperrno));
      (void)userlog("Clientfml failed to call the FMLTEST service -- %s \n",
                  tpstrerror(tperrno));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
  }

  for(i=0;i<3;i++){
        len2=10;
  if (Fget32(pF32rec, name, i, (char *)ptlr2[i].name, &len2) == -1) {
      (void)fprintf(stderr, "Failure to call get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)userlog("Clientfml failed to get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
  }
  len2=sizeof(long);
  if (Fget32(pF32rec, age, i, (char *)&ptlr2[i].age, &len2) == -1) {
      (void)fprintf(stderr, "Failure to call get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)userlog("Clientfml failed to get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
  }
  len2=12;
  if (Fget32(pF32rec, phone, i, (char *)ptlr2[i].phone, &len2) == -1) {
      (void)fprintf(stderr, "Failure to call get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)userlog("Clientfml failed to get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
  }
  len2=sizeof(long);
  if (Fget32(pF32rec, no, i, (char *)&ptlr2[i].no, &len2) == -1) {
      (void)fprintf(stderr, "Failure to call get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)userlog("Clientfml failed to get the result field -- %s \n",
                  Fstrerror32(Ferror32));
      (void)tpfree((char *)pF32);
      (void)tpfree((char *)pF32rec);
      (void)tpterm();
      (void)exit(1);
  }
        (void)fprintf(stdout,"%s %ld %s %ld\n",ptlr2[i].name,ptlr2[i].age,
        ptlr2[i].phone,ptlr2[i].no);

  }



  (void)tpfree((char *)pF32);
  (void)tpfree((char *)pF32rec);
  (void)tpterm();
  return(0);
}

[hwt@localhost fml]$ buildclient -o clientfml -f clientfml.c
clientfml.c:9: error: syntax error before numeric constant
clientfml.c:9: warning: no semicolon at end of struct or union
clientfml.c:10: error: syntax error before numeric constant
clientfml.c:11: error: syntax error before numeric constant
clientfml.c:15: error: syntax error before numeric constant
clientfml.c:15: warning: no semicolon at end of struct or union
clientfml.c:16: error: syntax error before numeric constant
clientfml.c:17: error: syntax error before numeric constant
clientfml.c:18: error: syntax error before numeric constant
clientfml.c: In function `main':
clientfml.c:63: error: storage size of 'ptlr' isn't known
clientfml.c:64: error: storage size of 'ptlr2' isn't known
clientfml.c:72: error: syntax error before '(' token
clientfml.c: At top level:
clientfml.c:78: error: syntax error before "for"
clientfml.c:139: warning: data definition has no type or storage class
clientfml.c:140: error: syntax error before "if"
clientfml.c:150: error: redefinition of 'len2'
clientfml.c:139: error: previous definition of 'len2' was here
clientfml.c:150: warning: data definition has no type or storage class
clientfml.c:151: error: syntax error before "if"
clientfml.c:161: error: redefinition of 'len2'
clientfml.c:150: error: previous definition of 'len2' was here
clientfml.c:161: error: redefinition of 'len2'
clientfml.c:150: error: previous definition of 'len2' was here
clientfml.c:161: warning: data definition has no type or storage class
clientfml.c:162: error: syntax error before "if"
CMDTUX_CAT:512: ERROR: Cannot execute C compiler cc   -I$TUXDIR/include -o clientfml   -L${TUXDIR}/lib clientfml.c  -ltux -lbuft  -lfml -lfml32 -lengine  -ldl -lpthread /usr/lib/libcrypt.a
搜索更多相关主题的帖子: 服务器 中间件 C语言 强人 
2011-04-23 21:38
flylee
Rank: 5Rank: 5
等 级:职业侠客
帖 子:309
专家分:374
注 册:2004-8-10
收藏
得分:13 
你把tuxedo的server和client放一起了吗?怎么还会有redefinition
2011-04-23 21:45
khaz
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:130
专家分:188
注 册:2011-4-21
收藏
得分:0 
以下是引用flylee在2011-4-23 21:45:27的发言:

你把tuxedo的server和client放一起了吗?怎么还会有redefinition
改成len3还是会redefinition,有点晕了 关键是怎么会一开始几行就有语法错。
2011-04-23 21:54
khaz
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:130
专家分:188
注 册:2011-4-21
收藏
得分:0 
郁闷了,原来是fmlfile的字段不能是小写的,改成大写就没错了!
2011-04-24 13:50
快速回复:tuxedo中间件C程序 找不到错误,编译总语法错误,各位大虾帮找找
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024795 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved