Function Pointer in C Struct
7 次查看(过去 30 天)
显示 更早的评论
I have a struct in custom C code that I included in my state_flow simulation:
typedef struct __UART_Message_Queue{
Queue_Lock lock;
int8_t queue_front;
int8_t queue_back;
uint32_t message_queue[16];
Queue_Status (* queue_push)(struct __UART_Message_Queue * queue, uint16_t header, uint16_t message);
uint32_t (* queue_pop)(struct __UART_Message_Queue * queue);
Queue_Status (* queue_status)(struct __UART_Message_Queue * queue);
}UART_Message_Queue;
and a function that I like to point to:
Queue_Status __queue_push(UART_Message_Queue* queue, uint16_t header, uint16_t message){
if(queue->queue_status(queue)==QUEUE_FULL){
return QUEUE_FULL;
}
else{
queue->queue_back = (queue->queue_back + 1) % 16;
queue->message_queue[queue->queue_back] = (((uint32_t)header)<<16U) + (uint32_t)message;
return QUEUE_NOT_FULL;
}
}
In my stateflow diagram, I assign:
UART_Message_Queue uart_queue;
uart_queue.queue_push = &__queue_push;
then when I call the "uart_queue.queue_push" function I get an error that the function is unresolved, but if I call the "__queue_push" everything is fine.
Has anybody faced this situation before?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!