I am coding on the IAR platform and want to do the following. I have a typedef
as follows
struct timer {
uint32_t start;
uint32_t 开发者_Go百科interval;
};
typedef (void) (*etimer_cb) (int,void*);
struct etimer {
struct timer timer;
struct etimer* next;
etimer_cb p;
};
After these I declare the following variable:
struct etimer periodic;
but it comes up with an error:
"periodic" is declared with a never completed type.
How do I resolve this?
Remove the ()
from around void
.
uint32_t
is not a predefined type. You need to #include <stdint.h>
.
#include <stdint.h>
struct timer{
uint32_t start;
uint32_t interval;
};
typedef void (*etimer_cb)(int, void *);
struct etimer{
struct timer timer;
struct etimer* next;
etimer_cb p;
};
But I prefer to NOT hide the pointerness of the function
#include <stdint.h>
struct timer{
uint32_t start;
uint32_t interval;
};
typedef void etimer_cb(int, void *);
struct etimer{
struct timer timer;
struct etimer* next;
etimer_cb *p;
};
精彩评论