java typedef struct,'struct ...'没有名为[closed]的成员

为什么我一直收到这个错误:

struct没有成员[-Wpedantic]'struct check'没有名为'refc'的成员'struct check'没有名为'valor'的成员

等 . 代码如下

#ifndef _ITEM_

#define _ITEM_

#include

#include

#include

#define key (a) (a != NULL ? a->refc : "")

#define less (a,b) (strcmp (a,b)<0)

#define eq(a,b) (strcmp (a,b) == 0)

#define NULLitem NULL

typedef long int* Key;

typedef struct cheque {

int valor

long int refe

long int refb

long int* refc

}*Item;

Item newItem (int valor, long int refe, long int refb, long int* refc);

void deleteItem (Item a);

void visitItem (Item a);

#endif

编辑:

现在我正面临着以下错误,

Item.c:6:36:错误:在'refe'之前预期';',','或')'项目newItem(int valor,long item refe,long item refb,long item * refc)^ Item.c :在函数'visitItem'中:Item.c:32:2:警告:格式'%d'需要类型为'int'的参数,但参数2的类型为'long int'[-Wformat =] printf(“refe:% d \ n“,a-> refe); ^ Item.c:33:2:警告:格式'%d'需要类型为'int'的参数,但参数2的类型为'long int'[-Wformat =] printf(“refb:%d \ n”,a - > REFB);代码如下

item.h

#ifndef _ITEM_

#define _ITEM_

#include

#include

#include

#define key (a) (a != NULL ? a->refc : "")

#define less (a,b) (strcmp (a,b)<0)

#define eq(a,b) (strcmp (a,b) == 0)

#define NULLitem NULL

typedef long int* Key;

typedef struct cheque {

int valor;

long int refe;

long int refb;

long int* refc;

}*Item;

Item newItem (int valor, long int refe, long int refb, long int* refc);

void deleteItem (Item a);

void visitItem (Item a);

#endif

item.c

#include "Item.h"

#include

#include

Item newItem (int valor, long item refe, long item refb, long item* refc)

{

Item x = (Item) malloc (sizeof(struct cheque));

x->valor = valor;

x->refe = refe;

x->refb = refb;

x->refc = strdup(refc);

return x;

}

void deleteItem (Item a)

{

free(a->refc);

free(a);

}

void visitItem (Item a)

{

printf("valor: %d\n", a->valor);

printf("refe: %d\n", a->refe);

printf("refb: %d\n", a->refb);

printf("refc: %ld\n", a->refc);

}

EDIT_v2

Item newItem (int valor, long int refe, long int refb, long int* refc)

printf("valor: %d\n", a->valor);

printf("refe: %ld\n", a->refe);

printf("refb: %ld\n", a->refb);

printf("refc: %p\n", a->refc);

在纠正这些错误后,我收到了以下错误:

Item.c:在函数'newItem'中:Item.c:14:2:warning:函数'strdup'的隐式声明[-Wimplicit-function-declaration] x-> refc = strdup(refc); ^ Item.c:14:10:警告:赋值从整数中生成没有强制转换的指针[默认启用] x-> refc = strdup(refc); Item.c:在函数'visitItem'中:Item.c:34:2:警告:格式'%p'需要类型为'void *'的参数,但参数2的类型为'long int *'[-Wformat =] printf (“refc:%p \ n”,a-> refc);

Edit_ v3

1问题修正纠正:

x->refc = refc;

错误atm:

Item.c:在函数'visitItem'中:Item.c:34:2:警告:格式'%p'需要'void *'类型的参数,但参数2的类型为'long int *'[-Wformat =] printf(“refc:%p \ n”,a-> refc);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值