免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5650 | 回复: 12
打印 上一主题 下一主题

parse error before [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-07-14 11:50 |只看该作者 |倒序浏览
我在头文件中定义

typedef struct
{
...;
}A;

typedef struct
{
...;
}B;

在C文件中定义
int func()
{
    A* pA = NULL;
    B* pB = NULL;
    ....;
}

用gcc编译时报
parse error before `pA'
parse error before `pB'

什么情况,真是郁闷

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2008-07-14 12:34 |只看该作者
从上面看不出啥问题。

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
3 [报告]
发表于 2008-07-14 12:35 |只看该作者
原帖由 tempname_cn 于 2008-7-14 11:50 发表
我在头文件中定义

typedef struct
{
...;
}A;

typedef struct
{
...;
}B;

在C文件中定义
int func()
{
    A* pA = NULL;
    B* pB = NULL;
    ....;
}

用gcc编译时报
parse error  ...



把两个struct详细信息贴出来,怀疑想使用链表

论坛徽章:
0
4 [报告]
发表于 2008-07-14 12:52 |只看该作者
没有使用链表

typedef struct
{
        char  flt_no[16+1];                /*flight number*/
        char  flt_date[16+1];                /*flight date*/
        float frei_weight;                /*货物重量*/
        int BUP_flg;                        /*BUP 标识*/
        char  container_no[11+1];        /*ULD集装箱号码*/
}BUPDLS_type;                                /*BUP(DLS)信息*/


typedef struct
{
        char  flt_no[16+1];                /*flight number*/
        char  flt_date[16+1];                /*flight date*/
        char  transit_no[13+1];                /*transit number 运单号*/
        char  batch_flg;                /*分批标识*/
        char  from_route[3+1];                /*航班始发站*/
        char  to_route[3+1];                /*航班目的站*/
        int  get_down_frei_flg;                /*拉下货物标识*/
        int   get_down_frei_num;        /*拉下货物件数*/
        float get_down_frei_weight;        /*拉下货物重量*/
}get_down_freight_type;                        /*拉下货物信息*/

有几个这样的struct,我就不一一列出来了,格式就是这样。

int SendDataToMQ()
{
        counter* cotr = NULL;
        exp_charge_type* exp_charge = NULL;
        flight_supplies_type* flt_sup = NULL;
        jiewei_freight_type* jiewei_frei = NULL;
        BUPDLS_type* bupdls = NULL;
        get_down_freight_type* get_down_frei = NULL;
        flight_freight_import* fri_frei_imp = NULL;
        flight_freight_export* fri_frei_exp = NULL;
        flight_freight_diversion* fri_frei_div = NULL;
        service_time_email* ser_time_email = NULL;

        time_t currtime;
            struct tm *tm_currtime;
        ......;

        currtime = time(NULL);
              tm_currtime = localtime(&currtime);

        ......;
}



exdata.c: In function `SendDataToMQ':
exdata.c:4280: parse error before `counter'
exdata.c:4288: parse error before `exp_charge_type'
exdata.c:4296: parse error before `flight_supplies_type'
exdata.c:4380: warning: implicit declaration of function `time'
exdata.c:4381: warning: implicit declaration of function `localtime'
exdata.c:4381: warning: assignment makes pointer from integer without a cast
exdata.c:4382: dereferencing pointer to incomplete type
exdata.c:4382: dereferencing pointer to incomplete type
exdata.c:4384: parse error before `get_down_freight_type'
exdata.c:4398: parse error before `get_down_freight_type'
exdata.c:4411: parse error before `BUPDLS_type'
exdata.c:4424: parse error before `flight_supplies_type'
exdata.c:4426: parse error before `flight_freight_import'
exdata.c:4438: parse error before `flight_freight_export'
exdata.c:4451: parse error before `flight_freight_diversion'
exdata.c:4464: parse error before `service_time_email'

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
5 [报告]
发表于 2008-07-14 12:55 |只看该作者
把指向NULL取消了,试一下

论坛徽章:
0
6 [报告]
发表于 2008-07-14 13:00 |只看该作者
不行啊,我真是不清楚有什么问题

Godbach
这是你邮箱吗?给我看看?SendDataToMQ函数?
nylzhaowei@163.com

论坛徽章:
0
7 [报告]
发表于 2008-07-14 13:14 |只看该作者
int SendDataToMQ()
{
        /* EXEC SQL BEGIN DECLARE SECTION; */

        char        cszUserId[80 + 1];
        char        szErr[128];
        char            buf[7000];
        /* EXEC SQL END DECLARE SECTION; */


        time_t currtime;
        struct tm* tm_currtime;


        counter* cotr = NULL;
        flight_supplies_type* flt_sup = NULL;
        jiewei_freight_type* jiewei_frei = NULL;
        BUPDLS_type* bupdls = NULL;
        get_down_freight_type* get_down_frei = NULL;
        flight_freight_import* fri_frei_imp = NULL;
        flight_freight_export* fri_frei_exp = NULL;
        flight_freight_diversion* fri_frei_div = NULL;
        service_time_email* ser_time_email = NULL;



        cotr = (counter*)malloc(counter);
        if(cotr == NULL)
        {
                WriteLogFile("SDMQ", "can not allocate memory for cotr", "");
                return FAILED;
        }

        exp_charge = (exp_charge_type*)malloc(exp_charge_type);
        if(exp_charge == NULL)
        {
                WriteLogFile("SDMQ", "can not allocate memory for exp_charge", "");
                return FAILED;
        }


        flt_sup = (flight_supplies_type*)malloc(flight_supplies_type);
        if(flt_sup == NULL)
        {
                WriteLogFile("SDMQ", "can not allocate memory for flt_sup", "");
                return FAILED;
        }


        memset(szErr, '\0', sizeof(szErr));
        memset(cszUserId, '\0', sizeof(cszUserId));
        memset(buf, '\0', sizeof(buf));

        ReadProfile(cszUserId, "USERID", getenv(EDIINI));

[ 本帖最后由 tempname_cn 于 2008-7-14 13:15 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2008-07-14 13:35 |只看该作者
问题已解决,是我自己的问题

论坛徽章:
0
9 [报告]
发表于 2008-07-14 13:55 |只看该作者
忘了引用头文件了?

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
10 [报告]
发表于 2008-07-14 14:14 |只看该作者
原帖由 tempname_cn 于 2008-7-14 13:35 发表
问题已解决,是我自己的问题



什么问题,可以分享一下吗
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP