A文件中调用B文件中含有结构体参数的函数

问题描述:

 

A.h

{

extern void B_switch(inton);//头文件中引入B文件中调用的函数

}

 

A.c

{

#include<A.h>

......

A_a(){

int aa=0,bb=1;

if(aa)

B_switch(aa);//调用函数

else

B_switch(bb);

......

}

}

 

B.c

{

union b_propval {

int intval;

const char *strval;

int64_t int64val;

};

 

struct msm_otg {

struct usb_phy phy;

struct msm_otg_platform_data *pdata;

int irq;

…...

}

 

static struct msm_otg  *b_for_typec = NULL;//定义一个全局的结构体变量来作为调用的参数

static intb_set_property_usb(struct b_supply *psy, enum b_property psp, constunion b_propval *val);//为真正调用的函数

 

void B_switch(int on)//新定义的函数来调用上面的函数,里面有结构体的参数

{

union b_propval val;

val.intval = on;

b_set_property_usb(&b_for_typec->b_psy,B_SUPPLY_PROP, &val);//函数调用

}

b_probe()

{

struct msm_otg *motg;

b_for_typec = motg; //probe的时候需要对定义的结构体赋值,指向另一个结构体成员即可

motg->b_psy.name = "ub";

…...

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值