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!