Я написал несколько упрощенный код, чтобы продемонстрировать случай. Цель состоит в том, чтобы вызвать некоторые функции из массива структуры. В этой реализации я получаю следующее замечание: «вызов функции« неопознанная функция »не сделан в присутствии прототипа»
Я предполагаю, что должны использоваться typedefs. Я просто не могу заставить его работать с typedefs.
#include <stdio.h>
#include<stdbool.h>
struct FuctionCallList
{
void (*const call_function)();
bool activated;
};
void testPrint1(void);
void testPrint2(void);
struct FuctionCallList sFuctionCallList[] =
{ //Function to call Activ
{testPrint1, false},
{testPrint2, true}
};
__uint16_t sFuctionCallListSize = sizeof(sFuctionCallList) / sizeof(struct FuctionCallList);
void testPrint1()
{
printf("Hello World function 1");
}
void testPrint2()
{
printf("Hello World function 2");
}
int main()
{
__uint8_t i;
for(i = 0; i < sFuctionCallListSize; i++)
{
if(sFuctionCallList[i].activated == true)
{
sFuctionCallList[i].call_function(); // problematic call
}
}
return 0;
}