[问题] struct call by reference

楼主: MaxHaru (懂得放手..才是王道)   2016-11-12 17:49:41
开发平台(Platform): (Ex: Win10, Linux, ...)
8051
编译器(Ex: GCC, clang, VC++...)+目标环境(跟开发平台不同的话需列出)
C51
问题(Question):
请问如何透过call by reference将struct中的pointer member传给function
例如:
typedef struct _AA
{
unsigned char Addr;
unsigned char bIndex;
unsigned char bLenAddrW;
unsigned char *pDatAddrW;
unsigned char bFlag; //bit0: Notify Busy
//bit1: CmdByte Get
//bit2: Address Write
}_AAA;
unsigned char Dat[10];
void func1(unsigned char*pLenAddrW, unsigned char**ppDatAddrW)
{
*pLenAddrW = aaa;
*ppDatAddrW = Dat;
}
void main(void)
{
_AAA AAA;
_AAA*pAAA = &AAA;
func1(???, ???); //请问要怎么透过pAAA将struct member的Address传给func1??
}
作者: stupid0319 (征女友)   2016-11-12 18:18:00
func1(&(pAAA->bLenAddrW),&(pAAA->pDatAddrW));
楼主: MaxHaru (懂得放手..才是王道)   2016-11-12 20:52:00
明白了, 十分感谢..
作者: azter (Yilin)   2016-11-15 07:49:00
1F, 喂给func1的第一个参数多了“&”?
作者: hunandy14 (Charlott.HonG)   2016-11-15 16:27:00
关键字 传参考
作者: LPH66 (-6.2598534e+18f)   2016-11-15 21:50:00
>azter 原 PO 就是要传指标进去改值>hunandy14 纯 C 的话没有传参考这回事喔, 只能这么做

Links booklink

Contact Us: admin [ a t ] ucptt.com