Home > Back-end >  [for] a function pointer and structure
[for] a function pointer and structure

Time:02-06

Structure member is u8, structure pointer, function pointer, the function pointer, two other members to address will be changed, the code is as follows, the first post have what not good place please forgive me , thank you,

1. The structure prototype and initialization:
Typedef struct
{
Uint8_t enableCRC;//CRC check can make
Buff UartBuff *;//serial port receive buffer data

Void * (Send) (uint8_t *, uint16_t);//send a serial port function
} UartPort;
UartPort uart2={false, & amp; Uart2Buff Uart2SendStr};

2. Uart2SendStr prototype:
Void Uart2SendStr (uint8_t * PSTR, uint16_t strlen)
{
uint16_t i;

for(i=0; iUart2SendByte (PSTR [I]);
}

3. The function call:
Void the debug (UartPort * uart)
{
.
Uart - & gt; Send (" 123 ", 3);
.
}

Test before the function call, the other two members address is normal, after the call address 0 x3300, 0 x0031,

CodePudding user response:

Point or test possible problems, also hope to provide the

CodePudding user response:

Post the complete code

CodePudding user response:

To clarify, what is the other two, what is normal,
Tell variable names respectively, original value, become what,
Additional initialization used when uart2Buff is a what thing, where is defined,

CodePudding user response:

Puzzling change this kind of matter, suspected return auto local variable address,

CodePudding user response:

Pointer is too much, don't say please call chain, which is the wild pointer carelessly,
  • Related